def compress(S):

    res = []

    prev = "aa"

    for c in S:

        if c != prev:

            res.append([c, 1])

        else:

            res[-1][1] += 1

        prev = c

    return res





N, K = list(map(int, input().split()))

S = list(map(int, eval(input())))

S_comp = compress(S)

M = len(S_comp)

ans = 0

total = 0

right = 0

zero_chunks_cnt = 0

for left in range(M):

    while right < M and zero_chunks_cnt + 1 - S_comp[right][0] <= K:

        zero_chunks_cnt += 1 - S_comp[right][0]

        total += S_comp[right][1]

        right += 1

    ans = max(ans, total)

    if right == left:

        right += 1

    else:

        zero_chunks_cnt -= 1 - S_comp[left][0]

        total -= S_comp[left][1]

print(ans)

def run_length_compress(S):

    res = [[S[0], 1]]

    for c in S[1:]:

        if c == res[-1][0]:

            res[-1][1] += 1

        else:

            res.append([c, 1])

    return res





N, K = list(map(int, input().split()))

S = eval(input())

cs = run_length_compress(S)

M = len(cs)



ans = 0

tot = 0

right = 0

zeros = 0

for left in range(M):

    while right < M and zeros + (cs[right][0] == "0") <= K:

        if cs[right][0] == "0":

            zeros += 1

        tot += cs[right][1]

        right += 1



    ans = max(ans, tot)



    if left == right:

        right += 1

    else:

        if cs[left][0] == "0":

            zeros -= 1

        tot -= cs[left][1]

print(ans)



def compress(S):
    res = []
    prev = "aa"
    for c in S:
        if c != prev:
            res.append([c, 1])
        else:
            res[-1][1] += 1
        prev = c
    return res


N, K = list(map(int, input().split()))
S = list(map(int, eval(input())))
S_comp = compress(S)
M = len(S_comp)
ans = 0
total = 0
right = 0
zero_chunks_cnt = 0
for left in range(M):
    while right < M and zero_chunks_cnt + 1 - S_comp[right][0] <= K:
        zero_chunks_cnt += 1 - S_comp[right][0]
        total += S_comp[right][1]
        right += 1
    ans = max(ans, total)
    if right == left:
        right += 1
    else:
        zero_chunks_cnt -= 1 - S_comp[left][0]
        total -= S_comp[left][1]
print(ans)

def run_length_compress(S):
    res = [[S[0], 1]]
    for c in S[1:]:
        if c == res[-1][0]:
            res[-1][1] += 1
        else:
            res.append([c, 1])
    return res


N, K = list(map(int, input().split()))
S = eval(input())
cs = run_length_compress(S)
M = len(cs)
ans = 0
tot = 0
right = 0
zeros = 0
for left in range(M):
    while right < M and zeros + (cs[right][0] == "0") <= K:
        if cs[right][0] == "0":
            zeros += 1
        tot += cs[right][1]
        right += 1
    ans = max(ans, tot)
    if left == right:
        right += 1
    else:
        if cs[left][0] == "0":
            zeros -= 1
        tot -= cs[left][1]
print(ans)

-def compress(S): -    res = [] -    prev = "aa" -    for c in S: -        if c != prev: +def run_length_compress(S): +    res = [[S[0], 1]] +    for c in S[1:]: +        if c == res[-1][0]: +            res[-1][1] += 1 +        else: -        else: -            res[-1][1] += 1 -        prev = c -S = list(map(int, eval(input()))) -S_comp = compress(S) -M = len(S_comp) +S = eval(input()) +cs = run_length_compress(S) +M = len(cs) -total = 0 +tot = 0 -zero_chunks_cnt = 0 +zeros = 0 -    while right < M and zero_chunks_cnt + 1 - S_comp[right][0] <= K: -        zero_chunks_cnt += 1 - S_comp[right][0] -        total += S_comp[right][1] +    while right < M and zeros + (cs[right][0] == "0") <= K: +        if cs[right][0] == "0": +            zeros += 1 +        tot += cs[right][1] -    ans = max(ans, total) -    if right == left: +    ans = max(ans, tot) +    if left == right: -        zero_chunks_cnt -= 1 - S_comp[left][0] -        total -= S_comp[left][1] +        if cs[left][0] == "0": +            zeros -= 1 +        tot -= cs[left][1]