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

sl = list(eval(input()))



l = []

l.append(0)

ans = 0

before = ""

count = 0

if sl[0] == "0":

   l.append(0)

for idx,s in enumerate(sl):

   if s != before:

      before = s

      if idx > 0:

         l.append(idx)

         if len(l) == 2*k + 2:

            ans = max(l[-1] - l[0], ans)

            l.pop(0)

            l.pop(0)

l.append(n)

ans = max(l[-1] - l[0], ans)

print(ans)
from collections import deque

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

sl = list(eval(input()))



d = deque([])

ans = 0

before = "1"

tmp = 0

p = 0

for s in sl:

    if before == s:

        p += 1

    else:

        d.append(p)

        tmp += p

        p = 1

        before = s

    if len(d) == 2 * k + 1:

        ans = max(tmp, ans)

        tmp -= d.popleft()

        tmp -= d.popleft()

else:

    d.append(p)

    tmp += p

    ans = max(tmp, ans)



print(ans)
n, k = list(map(int, input().split()))
sl = list(eval(input()))
l = []
l.append(0)
ans = 0
before = ""
count = 0
if sl[0] == "0":
    l.append(0)
for idx, s in enumerate(sl):
    if s != before:
        before = s
        if idx > 0:
            l.append(idx)
            if len(l) == 2 * k + 2:
                ans = max(l[-1] - l[0], ans)
                l.pop(0)
                l.pop(0)
l.append(n)
ans = max(l[-1] - l[0], ans)
print(ans)

from collections import deque

n, k = list(map(int, input().split()))
sl = list(eval(input()))
d = deque([])
ans = 0
before = "1"
tmp = 0
p = 0
for s in sl:
    if before == s:
        p += 1
    else:
        d.append(p)
        tmp += p
        p = 1
        before = s
    if len(d) == 2 * k + 1:
        ans = max(tmp, ans)
        tmp -= d.popleft()
        tmp -= d.popleft()
else:
    d.append(p)
    tmp += p
    ans = max(tmp, ans)
print(ans)

+from collections import deque + -l = [] -l.append(0) +d = deque([]) -before = "" -count = 0 -if sl[0] == "0": -    l.append(0) -for idx, s in enumerate(sl): -    if s != before: +before = "1" +tmp = 0 +p = 0 +for s in sl: +    if before == s: +        p += 1 +    else: +        d.append(p) +        tmp += p +        p = 1 -        if idx > 0: -            l.append(idx) -            if len(l) == 2 * k + 2: -                ans = max(l[-1] - l[0], ans) -                l.pop(0) -                l.pop(0) -l.append(n) -ans = max(l[-1] - l[0], ans) +    if len(d) == 2 * k + 1: +        ans = max(tmp, ans) +        tmp -= d.popleft() +        tmp -= d.popleft() +else: +    d.append(p) +    tmp += p +    ans = max(tmp, ans)