# -*- coding: utf-8 -*-

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

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



# Run Length Encoding

rle = list()

target = 1

count = 0

for i in range(n):

    if s[i] == target:

        count += 1

    else:

        target = 1 - target

        rle.append(count)

        count = 1

rle.append(count)

if target == 0:

    rle.append(0)



offset = 2 * k + 1

res = 0



# two pointers

left = 0

right = 0

cand = 0

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

    next_left = i

    next_right = min(i + offset, len(rle))



    while(next_left > left):

        cand -= rle[left]

        left += 1



    while(next_right > right):

        cand += rle[right]

        right += 1



    res = max(res, cand)



print(res)
# -*- coding: utf-8 -*-

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

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



# Run Length Encoding

rle = list()

target = 1

count = 0

for i in range(n):

    if s[i] == target:

        count += 1

    else:

        target = 1 - target

        rle.append(count)

        count = 1

rle.append(count)

if target == 0:

    rle.append(0)



offset = 2 * k + 1

res = 0



# cumsum

rle_cumsum = [0]

for i in range(len(rle)):

    rle_cumsum.append(rle_cumsum[i] + rle[i])





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

    left = i

    right = min(i + offset, len(rle))

    cand = rle_cumsum[right] - rle_cumsum[left]



    res = max(res, cand)



print(res)
# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
    if s[i] == target:
        count += 1
    else:
        target = 1 - target
        rle.append(count)
        count = 1
rle.append(count)
if target == 0:
    rle.append(0)
offset = 2 * k + 1
res = 0
# two pointers
left = 0
right = 0
cand = 0
for i in range(0, len(rle), 2):
    next_left = i
    next_right = min(i + offset, len(rle))
    while next_left > left:
        cand -= rle[left]
        left += 1
    while next_right > right:
        cand += rle[right]
        right += 1
    res = max(res, cand)
print(res)

# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
# Run Length Encoding
rle = list()
target = 1
count = 0
for i in range(n):
    if s[i] == target:
        count += 1
    else:
        target = 1 - target
        rle.append(count)
        count = 1
rle.append(count)
if target == 0:
    rle.append(0)
offset = 2 * k + 1
res = 0
# cumsum
rle_cumsum = [0]
for i in range(len(rle)):
    rle_cumsum.append(rle_cumsum[i] + rle[i])
for i in range(0, len(rle), 2):
    left = i
    right = min(i + offset, len(rle))
    cand = rle_cumsum[right] - rle_cumsum[left]
    res = max(res, cand)
print(res)

-# two pointers -left = 0 -right = 0 -cand = 0 +# cumsum +rle_cumsum = [0] +for i in range(len(rle)): +    rle_cumsum.append(rle_cumsum[i] + rle[i]) -    next_left = i -    next_right = min(i + offset, len(rle)) -    while next_left > left: -        cand -= rle[left] -        left += 1 -    while next_right > right: -        cand += rle[right] -        right += 1 +    left = i +    right = min(i + offset, len(rle)) +    cand = rle_cumsum[right] - rle_cumsum[left]