#参考　https://atcoder.jp/contests/abc124/submissions/4948803

from itertools import accumulate



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

p = list(eval(input()))

a = []

pre = '1'

cnt = 0

for i in range(n):

     if pre != p[i]:

          a.append(cnt)

          cnt = 1

          pre = p[i]

     else:

          cnt += 1

a.append(cnt)

if pre == '0':

     a.append(0)



w = 2*k+1



if w >= len(a):

     print(n)

else:

     acc = list(accumulate(a))

     ans = 0

     acc = [0] + acc

     for i in range(0,len(a)-w+1,2):

          ans = max(ans,acc[i+w]-acc[i])

     print(ans)
#参考　https://atcoder.jp/contests/abc124/submissions/4948803

from itertools import accumulate



def f():

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

     p = list(eval(input()))

     a = [] 

     pre = '1'

     cnt = 0

     for i in p:

          if pre != i:

               a.append(cnt)

               cnt = 1

               pre = i

          else:

               cnt += 1

     a.append(cnt)

     if pre == '0':

          a.append(0)



     w = 2*k+1



     if w >= len(a):

          return n

     else:

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

          ans = 0

          for i in range(0,len(a)-w+1,2):

               ans = max(ans,acc[i+w]-acc[i])

          return ans

          

print((f()))
# 参考　https://atcoder.jp/contests/abc124/submissions/4948803
from itertools import accumulate

n, k = list(map(int, input().split()))
p = list(eval(input()))
a = []
pre = "1"
cnt = 0
for i in range(n):
    if pre != p[i]:
        a.append(cnt)
        cnt = 1
        pre = p[i]
    else:
        cnt += 1
a.append(cnt)
if pre == "0":
    a.append(0)
w = 2 * k + 1
if w >= len(a):
    print(n)
else:
    acc = list(accumulate(a))
    ans = 0
    acc = [0] + acc
    for i in range(0, len(a) - w + 1, 2):
        ans = max(ans, acc[i + w] - acc[i])
    print(ans)

# 参考　https://atcoder.jp/contests/abc124/submissions/4948803
from itertools import accumulate


def f():
    n, k = list(map(int, input().split()))
    p = list(eval(input()))
    a = []
    pre = "1"
    cnt = 0
    for i in p:
        if pre != i:
            a.append(cnt)
            cnt = 1
            pre = i
        else:
            cnt += 1
    a.append(cnt)
    if pre == "0":
        a.append(0)
    w = 2 * k + 1
    if w >= len(a):
        return n
    else:
        acc = [0] + list(accumulate(a))
        ans = 0
        for i in range(0, len(a) - w + 1, 2):
            ans = max(ans, acc[i + w] - acc[i])
        return ans


print((f()))

-n, k = list(map(int, input().split())) -p = list(eval(input())) -a = [] -pre = "1" -cnt = 0 -for i in range(n): -    if pre != p[i]: -        a.append(cnt) -        cnt = 1 -        pre = p[i] + +def f(): +    n, k = list(map(int, input().split())) +    p = list(eval(input())) +    a = [] +    pre = "1" +    cnt = 0 +    for i in p: +        if pre != i: +            a.append(cnt) +            cnt = 1 +            pre = i +        else: +            cnt += 1 +    a.append(cnt) +    if pre == "0": +        a.append(0) +    w = 2 * k + 1 +    if w >= len(a): +        return n -        cnt += 1 -a.append(cnt) -if pre == "0": -    a.append(0) -w = 2 * k + 1 -if w >= len(a): -    print(n) -else: -    acc = list(accumulate(a)) -    ans = 0 -    acc = [0] + acc -    for i in range(0, len(a) - w + 1, 2): -        ans = max(ans, acc[i + w] - acc[i]) -    print(ans) +        acc = [0] + list(accumulate(a)) +        ans = 0 +        for i in range(0, len(a) - w + 1, 2): +            ans = max(ans, acc[i + w] - acc[i]) +        return ans + + +print((f()))