from itertools import accumulate as ac



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

*S, = list(map(int, eval(input())))



l = []

c0, c1 = 0, 0



prev = 0

for i, j  in enumerate(S):

    if i==0:

        if j==0:

            c0 += 1

        else:

            c1 += 1

    else:

        if prev!=j:

            if prev==1:

                l.append(c1)

                c1 = 0

            else:

                l.append(c0)

                c0 = 0

        if j==0:

            c0 += 1

        else:

            c1 += 1

    prev = j



if c0:

    l.append(c0)

if c1:

    l.append(c1)



if S[0]==0:

    l = [0]+l

if S[-1]==0:

    l.append(0)



size = len(l)

accum = list(ac([0]+l))

start = min(2*K+1,size)



ans = 0

for i in range(start, size+1, 2):

    ans = max(ans, accum[i]-accum[i-start])

print(ans)
from itertools import accumulate as ac



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

*S, = list(map(int, eval(input())))



l = []

c = 0



if N==1:

    l.append(S[0])

else:

    for i in range(N-1):

        c += 1

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

            l.append(c)

            c = 0

    if c:

        l.append(c+1)



if S[0]==0:

    l = [0]+l

if S[-1]==0:

    l.append(0)



size = len(l)

*a, = ac([0]+l)

group_size = min(2*K+1,size)



ans = 0

for i in range(group_size, size+1, 2):

    ans = max(ans, a[i]-a[i-group_size])

print(ans)
from itertools import accumulate as ac

N, K = list(map(int, input().split()))
(*S,) = list(map(int, eval(input())))
l = []
c0, c1 = 0, 0
prev = 0
for i, j in enumerate(S):
    if i == 0:
        if j == 0:
            c0 += 1
        else:
            c1 += 1
    else:
        if prev != j:
            if prev == 1:
                l.append(c1)
                c1 = 0
            else:
                l.append(c0)
                c0 = 0
        if j == 0:
            c0 += 1
        else:
            c1 += 1
    prev = j
if c0:
    l.append(c0)
if c1:
    l.append(c1)
if S[0] == 0:
    l = [0] + l
if S[-1] == 0:
    l.append(0)
size = len(l)
accum = list(ac([0] + l))
start = min(2 * K + 1, size)
ans = 0
for i in range(start, size + 1, 2):
    ans = max(ans, accum[i] - accum[i - start])
print(ans)

from itertools import accumulate as ac

N, K = list(map(int, input().split()))
(*S,) = list(map(int, eval(input())))
l = []
c = 0
if N == 1:
    l.append(S[0])
else:
    for i in range(N - 1):
        c += 1
        if S[i] != S[i + 1]:
            l.append(c)
            c = 0
    if c:
        l.append(c + 1)
if S[0] == 0:
    l = [0] + l
if S[-1] == 0:
    l.append(0)
size = len(l)
(*a,) = ac([0] + l)
group_size = min(2 * K + 1, size)
ans = 0
for i in range(group_size, size + 1, 2):
    ans = max(ans, a[i] - a[i - group_size])
print(ans)

-c0, c1 = 0, 0 -prev = 0 -for i, j in enumerate(S): -    if i == 0: -        if j == 0: -            c0 += 1 -        else: -            c1 += 1 -    else: -        if prev != j: -            if prev == 1: -                l.append(c1) -                c1 = 0 -            else: -                l.append(c0) -                c0 = 0 -        if j == 0: -            c0 += 1 -        else: -            c1 += 1 -    prev = j -if c0: -    l.append(c0) -if c1: -    l.append(c1) +c = 0 +if N == 1: +    l.append(S[0]) +else: +    for i in range(N - 1): +        c += 1 +        if S[i] != S[i + 1]: +            l.append(c) +            c = 0 +    if c: +        l.append(c + 1) -accum = list(ac([0] + l)) -start = min(2 * K + 1, size) +(*a,) = ac([0] + l) +group_size = min(2 * K + 1, size) -for i in range(start, size + 1, 2): -    ans = max(ans, accum[i] - accum[i - start]) +for i in range(group_size, size + 1, 2): +    ans = max(ans, a[i] - a[i - group_size])