import numpy as np



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

S = np.array([int(x) for x in eval(input())] + [2])



blocks = [] # 同じ数の塊

seq = 1

for i in range(N):

    if S[i+1] == S[i]:

        seq += 1

    else:

        blocks.append(seq)

        seq = 1

blocks = np.array(blocks)



answer = blocks[:2*K].sum()



start = 0 if S[0] == 1 else 1

for i in range(start, len(blocks), 2):

    answer = max(answer, blocks[i:i+(2*K+1)].sum())



print(answer)
import numpy as np



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

S = [int(x) for x in eval(input())]



cur = 1 # 最初は1が0人立っている

blocks = np.zeros(10**5+1, dtype = np.int64)

seq = 0

p = 0

for s in S:

    if s == cur:

        blocks[p] += 1

    else:

        p += 1

        blocks[p] += 1        

        cur = 1 - cur

W = min(2*K, 10**5)

answer = sum = blocks[:W+1].sum()

for i in range(W+1, 10**5, 2):

    if i+1 > 10 ** 5:

        break

    sum = sum + blocks[i] + blocks[i+1] - blocks[i-W-1] - blocks[i-W]

    if sum > answer:

        answer = sum

print(answer)
import numpy as np

N, K = list(map(int, input().split()))
S = np.array([int(x) for x in eval(input())] + [2])
blocks = []  # 同じ数の塊
seq = 1
for i in range(N):
    if S[i + 1] == S[i]:
        seq += 1
    else:
        blocks.append(seq)
        seq = 1
blocks = np.array(blocks)
answer = blocks[: 2 * K].sum()
start = 0 if S[0] == 1 else 1
for i in range(start, len(blocks), 2):
    answer = max(answer, blocks[i : i + (2 * K + 1)].sum())
print(answer)

import numpy as np

N, K = list(map(int, input().split()))
S = [int(x) for x in eval(input())]
cur = 1  # 最初は1が0人立っている
blocks = np.zeros(10**5 + 1, dtype=np.int64)
seq = 0
p = 0
for s in S:
    if s == cur:
        blocks[p] += 1
    else:
        p += 1
        blocks[p] += 1
        cur = 1 - cur
W = min(2 * K, 10**5)
answer = sum = blocks[: W + 1].sum()
for i in range(W + 1, 10**5, 2):
    if i + 1 > 10**5:
        break
    sum = sum + blocks[i] + blocks[i + 1] - blocks[i - W - 1] - blocks[i - W]
    if sum > answer:
        answer = sum
print(answer)

-S = np.array([int(x) for x in eval(input())] + [2]) -blocks = []  # 同じ数の塊 -seq = 1 -for i in range(N): -    if S[i + 1] == S[i]: -        seq += 1 +S = [int(x) for x in eval(input())] +cur = 1  # 最初は1が0人立っている +blocks = np.zeros(10**5 + 1, dtype=np.int64) +seq = 0 +p = 0 +for s in S: +    if s == cur: +        blocks[p] += 1 -        blocks.append(seq) -        seq = 1 -blocks = np.array(blocks) -answer = blocks[: 2 * K].sum() -start = 0 if S[0] == 1 else 1 -for i in range(start, len(blocks), 2): -    answer = max(answer, blocks[i : i + (2 * K + 1)].sum()) +        p += 1 +        blocks[p] += 1 +        cur = 1 - cur +W = min(2 * K, 10**5) +answer = sum = blocks[: W + 1].sum() +for i in range(W + 1, 10**5, 2): +    if i + 1 > 10**5: +        break +    sum = sum + blocks[i] + blocks[i + 1] - blocks[i - W - 1] - blocks[i - W] +    if sum > answer: +        answer = sum