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

s = eval(input())



l, accum = len(s), []

i = 0

while i < l:

    ch = s[i]

    count = 0

    while i < l and s[i] == ch:

        count += 1

        i += 1

    accum.append(count)



l = len(accum)

for i in range(1, l): accum[i] += accum[i-1]



mx = accum[min(2*k - (1-int(s[0])), l-1)]

i = 1

while l > 1:

    idx = min(2*k - (1-int(s[0])) + 2*i, l-1)

    mx = max(accum[idx] - accum[2*(i-1)+int(s[0])], mx)

    if idx >= l-1: break

    i += 1

print(mx) 
N, k = list(map(int, input().split()))                                                                               

s = eval(input())

l, accum = len(s), []

zeros, ones = [], []

if s[0] == '0':

    ones = [0]

i = 0

while i < l:

    ch = s[i]

    if ch == '0':

        count = 0

        while i < l and s[i] == ch:

            count += 1

            i += 1

        zeros.append(count)

    elif ch == '1':

        count = 0

        while i < l and s[i] == ch:

            count += 1

            i += 1

        ones.append(count)

mx = sum(zeros[:k]) + sum(ones[:k+1])

ones+=[0]

for i in range(1, len(zeros)): zeros[i] += zeros[i-1]

for i in range(1, len(ones)): ones[i] += ones[i-1]

for i in range(1, len(zeros)-k+1):

    mx = max(zeros[k+i-1] + ones[k+i] - zeros[i-1] - ones[i-1], mx)

print(mx)
N, k = list(map(int, input().split()))
s = eval(input())
l, accum = len(s), []
i = 0
while i < l:
    ch = s[i]
    count = 0
    while i < l and s[i] == ch:
        count += 1
        i += 1
    accum.append(count)
l = len(accum)
for i in range(1, l):
    accum[i] += accum[i - 1]
mx = accum[min(2 * k - (1 - int(s[0])), l - 1)]
i = 1
while l > 1:
    idx = min(2 * k - (1 - int(s[0])) + 2 * i, l - 1)
    mx = max(accum[idx] - accum[2 * (i - 1) + int(s[0])], mx)
    if idx >= l - 1:
        break
    i += 1
print(mx)

N, k = list(map(int, input().split()))
s = eval(input())
l, accum = len(s), []
zeros, ones = [], []
if s[0] == "0":
    ones = [0]
i = 0
while i < l:
    ch = s[i]
    if ch == "0":
        count = 0
        while i < l and s[i] == ch:
            count += 1
            i += 1
        zeros.append(count)
    elif ch == "1":
        count = 0
        while i < l and s[i] == ch:
            count += 1
            i += 1
        ones.append(count)
mx = sum(zeros[:k]) + sum(ones[: k + 1])
ones += [0]
for i in range(1, len(zeros)):
    zeros[i] += zeros[i - 1]
for i in range(1, len(ones)):
    ones[i] += ones[i - 1]
for i in range(1, len(zeros) - k + 1):
    mx = max(zeros[k + i - 1] + ones[k + i] - zeros[i - 1] - ones[i - 1], mx)
print(mx)

+zeros, ones = [], [] +if s[0] == "0": +    ones = [0] -    count = 0 -    while i < l and s[i] == ch: -        count += 1 -        i += 1 -    accum.append(count) -l = len(accum) -for i in range(1, l): -    accum[i] += accum[i - 1] -mx = accum[min(2 * k - (1 - int(s[0])), l - 1)] -i = 1 -while l > 1: -    idx = min(2 * k - (1 - int(s[0])) + 2 * i, l - 1) -    mx = max(accum[idx] - accum[2 * (i - 1) + int(s[0])], mx) -    if idx >= l - 1: -        break -    i += 1 +    if ch == "0": +        count = 0 +        while i < l and s[i] == ch: +            count += 1 +            i += 1 +        zeros.append(count) +    elif ch == "1": +        count = 0 +        while i < l and s[i] == ch: +            count += 1 +            i += 1 +        ones.append(count) +mx = sum(zeros[:k]) + sum(ones[: k + 1]) +ones += [0] +for i in range(1, len(zeros)): +    zeros[i] += zeros[i - 1] +for i in range(1, len(ones)): +    ones[i] += ones[i - 1] +for i in range(1, len(zeros) - k + 1): +    mx = max(zeros[k + i - 1] + ones[k + i] - zeros[i - 1] - ones[i - 1], mx)