from bisect import bisect_left, bisect_right

from collections import Counter, defaultdict, deque, OrderedDict

from copy import deepcopy

from fractions import gcd

from functools import lru_cache, reduce

from math import ceil, floor

from sys import setrecursionlimit



import heapq

import itertools

import operator





# globals

inf = float('inf')

N, K = 0, 0

S = ""

M = 300000





def set_inputs():

    global N, K, S

    N, K = get_li()

    S = get_str()

    return





def main():

    setrecursionlimit(100000)

    set_inputs()

    # ----------MAIN----------

    cont = []

    cur = S[0]

    count = 1

    for s in S[1:]:

        if cur == s:

            count += 1

        else:

            cont.append((count, cur == "1"))

            cur = s

            count = 1

    cont.append((count, cur == "1"))

    

    lc = len(cont)

    if lc == 1:

        print((len(S)))

        return

    cont = cont + ([(0, None)] * M)

    if cont[0][1] == False:

        cont = [(0, None)] + cont

    ans = 0

    tmp = sum(map(operator.itemgetter(0), cont[:2*K+1]))

    ans = tmp

    i = 2

    while i < lc + 1:

        tmp = tmp - cont[i-2][0] - cont[i-1][0] + cont[i+2*K-1][0] + cont[i+2*K][0]

        ans = max(ans, tmp)

        i += 2

    print(ans)

    return





def get_int():

    return int(eval(input()))





def get_float():

    return float(eval(input()))





def get_str():

    return input().strip()





def get_li():

    return [int(i) for i in input().split()]





def get_lf():

    return [float(f) for f in input().split()]





def get_lc():

    return list(input().strip())





def get_data(n, types, sep=None):

    if len(types) == 1:

        return [types[0](eval(input())) for _ in range(n)]

    return list(zip(*(

        [t(x) for t, x in zip(types, input().split(sep=sep))]

        for _ in range(n)

    )))





if __name__ == '__main__':

    main()

from bisect import bisect_left, bisect_right

from collections import Counter, defaultdict, deque, OrderedDict

from copy import deepcopy

from fractions import gcd

from functools import lru_cache, reduce

from math import ceil, floor

from sys import setrecursionlimit



import heapq

import itertools

import operator





# globals

inf = float('inf')

N, K = 0, 0

S = ""

M = 300000





def set_inputs():

    global N, K, S

    N, K = get_li()

    S = get_str()

    return





def main():

    setrecursionlimit(100000)

    set_inputs()

    # ----------MAIN----------

    cont = []

    cur = S[0]

    count = 1

    for s in S[1:]:

        if cur == s:

            count += 1

        else:

            cont.append(count)

            cur = s

            count = 1

    cont.append(count)

    

    lc = len(cont)

    if lc == 1:

        print((len(S)))

        return

    cont = cont + ([0] * M)

    if S[0] == "0":

        cont = [0] + cont

    ans = 0

    tmp = sum(cont[:2*K+1])

    ans = tmp

    i = 2

    while i < lc + 1:

        tmp = tmp - cont[i-2] - cont[i-1] + cont[i+2*K-1] + cont[i+2*K]

        ans = max(ans, tmp)

        i += 2

    print(ans)

    return





def get_int():

    return int(eval(input()))





def get_float():

    return float(eval(input()))





def get_str():

    return input().strip()





def get_li():

    return [int(i) for i in input().split()]





def get_lf():

    return [float(f) for f in input().split()]





def get_lc():

    return list(input().strip())





def get_data(n, types, sep=None):

    if len(types) == 1:

        return [types[0](eval(input())) for _ in range(n)]

    return list(zip(*(

        [t(x) for t, x in zip(types, input().split(sep=sep))]

        for _ in range(n)

    )))





if __name__ == '__main__':

    main()

from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit
import heapq
import itertools
import operator

# globals
inf = float("inf")
N, K = 0, 0
S = ""
M = 300000


def set_inputs():
    global N, K, S
    N, K = get_li()
    S = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    cont = []
    cur = S[0]
    count = 1
    for s in S[1:]:
        if cur == s:
            count += 1
        else:
            cont.append((count, cur == "1"))
            cur = s
            count = 1
    cont.append((count, cur == "1"))
    lc = len(cont)
    if lc == 1:
        print((len(S)))
        return
    cont = cont + ([(0, None)] * M)
    if cont[0][1] == False:
        cont = [(0, None)] + cont
    ans = 0
    tmp = sum(map(operator.itemgetter(0), cont[: 2 * K + 1]))
    ans = tmp
    i = 2
    while i < lc + 1:
        tmp = (
            tmp
            - cont[i - 2][0]
            - cont[i - 1][0]
            + cont[i + 2 * K - 1][0]
            + cont[i + 2 * K][0]
        )
        ans = max(ans, tmp)
        i += 2
    print(ans)
    return


def get_int():
    return int(eval(input()))


def get_float():
    return float(eval(input()))


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](eval(input())) for _ in range(n)]
    return list(
        zip(*([t(x) for t, x in zip(types, input().split(sep=sep))] for _ in range(n)))
    )


if __name__ == "__main__":
    main()

from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit
import heapq
import itertools
import operator

# globals
inf = float("inf")
N, K = 0, 0
S = ""
M = 300000


def set_inputs():
    global N, K, S
    N, K = get_li()
    S = get_str()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    cont = []
    cur = S[0]
    count = 1
    for s in S[1:]:
        if cur == s:
            count += 1
        else:
            cont.append(count)
            cur = s
            count = 1
    cont.append(count)
    lc = len(cont)
    if lc == 1:
        print((len(S)))
        return
    cont = cont + ([0] * M)
    if S[0] == "0":
        cont = [0] + cont
    ans = 0
    tmp = sum(cont[: 2 * K + 1])
    ans = tmp
    i = 2
    while i < lc + 1:
        tmp = tmp - cont[i - 2] - cont[i - 1] + cont[i + 2 * K - 1] + cont[i + 2 * K]
        ans = max(ans, tmp)
        i += 2
    print(ans)
    return


def get_int():
    return int(eval(input()))


def get_float():
    return float(eval(input()))


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](eval(input())) for _ in range(n)]
    return list(
        zip(*([t(x) for t, x in zip(types, input().split(sep=sep))] for _ in range(n)))
    )


if __name__ == "__main__":
    main()

-            cont.append((count, cur == "1")) +            cont.append(count) -    cont.append((count, cur == "1")) +    cont.append(count) -    cont = cont + ([(0, None)] * M) -    if cont[0][1] == False: -        cont = [(0, None)] + cont +    cont = cont + ([0] * M) +    if S[0] == "0": +        cont = [0] + cont -    tmp = sum(map(operator.itemgetter(0), cont[: 2 * K + 1])) +    tmp = sum(cont[: 2 * K + 1]) -        tmp = ( -            tmp -            - cont[i - 2][0] -            - cont[i - 1][0] -            + cont[i + 2 * K - 1][0] -            + cont[i + 2 * K][0] -        ) +        tmp = tmp - cont[i - 2] - cont[i - 1] + cont[i + 2 * K - 1] + cont[i + 2 * K]