import numpy as np



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

S = list(eval(input())) + ['2']



blocks = []

cur = 1

seq = 0

for s in S:

    if int(s) == cur:

        seq += 1

    else:

        blocks.append(seq)

        cur = 1 - cur

        seq = 1

answer = 0

blocks = np.array(blocks)

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

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

print(answer)

# coding: utf-8

import sys

import itertools



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



# 0か1の連続している人数のリスト、累積和

streak = [0, 0]

N, K = lr()

S = sr() + '2'

cur = 1

for i in range(N):

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

        streak.append(cur)

        cur = 1

    else:

        cur += 1



streak_cum = list(itertools.accumulate(streak))

streak_cum.extend([streak_cum[-1], streak_cum[-1]])

if S[0] == '0':

    start = 0

else:

    start = 1

answer = 0



limit = len(streak_cum) - 1

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

    result = streak_cum[min(limit, i+2*K+1)] - streak_cum[i]

    if result > answer:

        answer = result



print(answer)

# 52
import numpy as np

N, K = list(map(int, input().split()))
S = list(eval(input())) + ["2"]
blocks = []
cur = 1
seq = 0
for s in S:
    if int(s) == cur:
        seq += 1
    else:
        blocks.append(seq)
        cur = 1 - cur
        seq = 1
answer = 0
blocks = np.array(blocks)
for i in range(0, len(blocks), 2):
    answer = max(answer, blocks[i : i + 2 * K + 1].sum())
print(answer)

# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 0か1の連続している人数のリスト、累積和
streak = [0, 0]
N, K = lr()
S = sr() + "2"
cur = 1
for i in range(N):
    if S[i] != S[i + 1]:
        streak.append(cur)
        cur = 1
    else:
        cur += 1
streak_cum = list(itertools.accumulate(streak))
streak_cum.extend([streak_cum[-1], streak_cum[-1]])
if S[0] == "0":
    start = 0
else:
    start = 1
answer = 0
limit = len(streak_cum) - 1
for i in range(start, len(streak_cum), 2):
    result = streak_cum[min(limit, i + 2 * K + 1)] - streak_cum[i]
    if result > answer:
        answer = result
print(answer)
# 52

-import numpy as np +# coding: utf-8 +import sys +import itertools -N, K = list(map(int, input().split())) -S = list(eval(input())) + ["2"] -blocks = [] +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) +# 0か1の連続している人数のリスト、累積和 +streak = [0, 0] +N, K = lr() +S = sr() + "2" -seq = 0 -for s in S: -    if int(s) == cur: -        seq += 1 +for i in range(N): +    if S[i] != S[i + 1]: +        streak.append(cur) +        cur = 1 -        blocks.append(seq) -        cur = 1 - cur -        seq = 1 +        cur += 1 +streak_cum = list(itertools.accumulate(streak)) +streak_cum.extend([streak_cum[-1], streak_cum[-1]]) +if S[0] == "0": +    start = 0 +else: +    start = 1 -blocks = np.array(blocks) -for i in range(0, len(blocks), 2): -    answer = max(answer, blocks[i : i + 2 * K + 1].sum()) +limit = len(streak_cum) - 1 +for i in range(start, len(streak_cum), 2): +    result = streak_cum[min(limit, i + 2 * K + 1)] - streak_cum[i] +    if result > answer: +        answer = result +# 52