import sys



n, k = list(map(int, input().split()))

s = [int(s) for s in list(eval(input()))]

count = 0

tmp = 1

c = []

ans = 0



for i in s:

    if i == tmp:

        count += 1

    else:

        c.append(count)

        tmp = i

        count = 1



c.append(count)

if s[-1] == 0:

    c.append(0)



# kが十分大きいなら

if len(c) <= 2*k+1:

    print((sum(c)))

    sys.exit()

# TLEしたから尺取りにしたい

# for i in range(0, len(c)-2*k, 2):

#     ans = max(ans, sum(c[i:i+2*k+1]))

ans = total = sum(c[:2*k+1])

for i in range(0, len(c)-2*k-2, 2):

    total = total + c[i+2*k+1] + c[i+2*k+2] - c[i] - c[i+1]

    ans = max(ans, total)



print(ans)

n, k = list(map(int, input().split()))

s = [int(s) for s in list(eval(input()))]

count = 0

tmp = 1

c = []



for i in s:

    if i == tmp:

        count += 1

    else:

        c.append(count)

        tmp = i

        count = 1



c.append(count)

if s[-1] == 0:

    c.append(0)



if len(c) <= 2*k+1:

    ans = sum(c)

else:

    ans = total = sum(c[:2*k+1])

    for i in range(0, len(c)-2*k-2, 2):

        total = total + c[i+2*k+1] + c[i+2*k+2] - c[i] - c[i+1]

        ans = max(ans, total)



print(ans)

import sys

n, k = list(map(int, input().split()))
s = [int(s) for s in list(eval(input()))]
count = 0
tmp = 1
c = []
ans = 0
for i in s:
    if i == tmp:
        count += 1
    else:
        c.append(count)
        tmp = i
        count = 1
c.append(count)
if s[-1] == 0:
    c.append(0)
# kが十分大きいなら
if len(c) <= 2 * k + 1:
    print((sum(c)))
    sys.exit()
# TLEしたから尺取りにしたい
# for i in range(0, len(c)-2*k, 2):
#     ans = max(ans, sum(c[i:i+2*k+1]))
ans = total = sum(c[: 2 * k + 1])
for i in range(0, len(c) - 2 * k - 2, 2):
    total = total + c[i + 2 * k + 1] + c[i + 2 * k + 2] - c[i] - c[i + 1]
    ans = max(ans, total)
print(ans)

n, k = list(map(int, input().split()))
s = [int(s) for s in list(eval(input()))]
count = 0
tmp = 1
c = []
for i in s:
    if i == tmp:
        count += 1
    else:
        c.append(count)
        tmp = i
        count = 1
c.append(count)
if s[-1] == 0:
    c.append(0)
if len(c) <= 2 * k + 1:
    ans = sum(c)
else:
    ans = total = sum(c[: 2 * k + 1])
    for i in range(0, len(c) - 2 * k - 2, 2):
        total = total + c[i + 2 * k + 1] + c[i + 2 * k + 2] - c[i] - c[i + 1]
        ans = max(ans, total)
print(ans)

-import sys - -ans = 0 -# kが十分大きいなら -    print((sum(c))) -    sys.exit() -# TLEしたから尺取りにしたい -# for i in range(0, len(c)-2*k, 2): -#     ans = max(ans, sum(c[i:i+2*k+1])) -ans = total = sum(c[: 2 * k + 1]) -for i in range(0, len(c) - 2 * k - 2, 2): -    total = total + c[i + 2 * k + 1] + c[i + 2 * k + 2] - c[i] - c[i + 1] -    ans = max(ans, total) +    ans = sum(c) +else: +    ans = total = sum(c[: 2 * k + 1]) +    for i in range(0, len(c) - 2 * k - 2, 2): +        total = total + c[i + 2 * k + 1] + c[i + 2 * k + 2] - c[i] - c[i + 1] +        ans = max(ans, total)