from itertools import accumulate

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

s = eval(input())

a = []

i = 0

cnt = 0

now = s[0]

while i < n:

    if s[i] == now:

        cnt += 1

    else:

        a.append(cnt)

        now = s[i]

        cnt = 1

    if i == n-1:

        a.append(cnt)

    i += 1



if len(a) == 1 and s[0] == '1':

    print(n)

    exit()



if s[0] == '0':

    a = [0] + a

if s[-1] == '0':

    a.append(0)

    

r = list(accumulate(a))

lr = len(r)

ans = -float('inf')

kk = 2*k+1

for i in range(k*2, lr+1 , 2):

    if i == k*2:

        ans = max(ans, r[i])

    else:

        ans = max(ans, r[i] - r[i-kk])

        

if ans == -float('inf'):

    print(n)

    exit()

print(ans)
from itertools import accumulate

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

s = eval(input())

a = []

cnt = 0

now = s[0]

for ss in s:

    if ss == now:

        cnt += 1

    else:

        a.append(cnt)

        cnt = 1

        now = ss

a.append(cnt)



a = [0]*(1-int(s[0])) + a + [0]*(1-int(s[-1]))

la = len(a)

kk = 2*k+1

if la == 1 or la <= kk:

    print(n)

    exit()

    

ac = [0] + list(accumulate(a))

ans = -float('inf')

for i in range(kk, la+1, 2):

    ans = max(ans, ac[i] - ac[i-kk])

print(ans)
from itertools import accumulate

n, k = list(map(int, input().split()))
s = eval(input())
a = []
i = 0
cnt = 0
now = s[0]
while i < n:
    if s[i] == now:
        cnt += 1
    else:
        a.append(cnt)
        now = s[i]
        cnt = 1
    if i == n - 1:
        a.append(cnt)
    i += 1
if len(a) == 1 and s[0] == "1":
    print(n)
    exit()
if s[0] == "0":
    a = [0] + a
if s[-1] == "0":
    a.append(0)
r = list(accumulate(a))
lr = len(r)
ans = -float("inf")
kk = 2 * k + 1
for i in range(k * 2, lr + 1, 2):
    if i == k * 2:
        ans = max(ans, r[i])
    else:
        ans = max(ans, r[i] - r[i - kk])
if ans == -float("inf"):
    print(n)
    exit()
print(ans)

from itertools import accumulate

n, k = list(map(int, input().split()))
s = eval(input())
a = []
cnt = 0
now = s[0]
for ss in s:
    if ss == now:
        cnt += 1
    else:
        a.append(cnt)
        cnt = 1
        now = ss
a.append(cnt)
a = [0] * (1 - int(s[0])) + a + [0] * (1 - int(s[-1]))
la = len(a)
kk = 2 * k + 1
if la == 1 or la <= kk:
    print(n)
    exit()
ac = [0] + list(accumulate(a))
ans = -float("inf")
for i in range(kk, la + 1, 2):
    ans = max(ans, ac[i] - ac[i - kk])
print(ans)

-i = 0 -while i < n: -    if s[i] == now: +for ss in s: +    if ss == now: -        now = s[i] -    if i == n - 1: -        a.append(cnt) -    i += 1 -if len(a) == 1 and s[0] == "1": +        now = ss +a.append(cnt) +a = [0] * (1 - int(s[0])) + a + [0] * (1 - int(s[-1])) +la = len(a) +kk = 2 * k + 1 +if la == 1 or la <= kk: -if s[0] == "0": -    a = [0] + a -if s[-1] == "0": -    a.append(0) -r = list(accumulate(a)) -lr = len(r) +ac = [0] + list(accumulate(a)) -kk = 2 * k + 1 -for i in range(k * 2, lr + 1, 2): -    if i == k * 2: -        ans = max(ans, r[i]) -    else: -        ans = max(ans, r[i] - r[i - kk]) -if ans == -float("inf"): -    print(n) -    exit() +for i in range(kk, la + 1, 2): +    ans = max(ans, ac[i] - ac[i - kk])