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

s=list(eval(input()))

s=list(map(int,s))

stack=[]

tmp=0

now=1

for i in range(n):

  if s[i]==now:

    tmp+=1

  else:

    stack.append(tmp)

    tmp=1

    now=1-now

stack.append(tmp)

if len(stack)%2==0:

  stack.append(0)

Acc=[0]*(len(stack)+1)

for i in range(len(stack)):

  Acc[i+1]=Acc[i]+stack[i]

ans=0

for i in range(0,len(stack),2):

  left = i

  right = min(i+k*2+1,len(stack))

  ans=max(ans,Acc[right]-Acc[left])

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

s=list(eval(input()))

s=list(map(int,s))

stack=[]

tmp=1

flag=True

for i in range(1,len(s)):

  if s[i]!=s[i-1]:

    stack.append(tmp)

    tmp=1

  else:

    tmp+=1

stack.append(tmp)

left=[0]

right=[0]

tmp=0

if s[0]==0:

  flag=False

  if len(stack)%2==1:

    stack.append(0)

  if len(stack)//2<=k:

    print((len(s)))

    exit()

else:

  if len(stack)%2==0:

    stack.append(0)

  if len(stack)//2<=k:

    print((len(s)))

    exit()

for i in range(len(stack)):

  tmp+=stack[i]

  if i%2==0:

    if flag:

      right.append(tmp)

    else:

      left.append(tmp)

  else:

    if flag:

      left.append(tmp)

    else:

      right.append(tmp)

ans=0

if flag:

    for i in range(len(right)-k-1):

      ans=max(ans,right[i+k+1]-left[i])

else:

  for i in range(len(right)-k):

    ans=max(ans,right[i+k]-left[i])

print(ans)

n, k = list(map(int, input().split()))
s = list(eval(input()))
s = list(map(int, s))
stack = []
tmp = 0
now = 1
for i in range(n):
    if s[i] == now:
        tmp += 1
    else:
        stack.append(tmp)
        tmp = 1
        now = 1 - now
stack.append(tmp)
if len(stack) % 2 == 0:
    stack.append(0)
Acc = [0] * (len(stack) + 1)
for i in range(len(stack)):
    Acc[i + 1] = Acc[i] + stack[i]
ans = 0
for i in range(0, len(stack), 2):
    left = i
    right = min(i + k * 2 + 1, len(stack))
    ans = max(ans, Acc[right] - Acc[left])
print(ans)

n, k = list(map(int, input().split()))
s = list(eval(input()))
s = list(map(int, s))
stack = []
tmp = 1
flag = True
for i in range(1, len(s)):
    if s[i] != s[i - 1]:
        stack.append(tmp)
        tmp = 1
    else:
        tmp += 1
stack.append(tmp)
left = [0]
right = [0]
tmp = 0
if s[0] == 0:
    flag = False
    if len(stack) % 2 == 1:
        stack.append(0)
    if len(stack) // 2 <= k:
        print((len(s)))
        exit()
else:
    if len(stack) % 2 == 0:
        stack.append(0)
    if len(stack) // 2 <= k:
        print((len(s)))
        exit()
for i in range(len(stack)):
    tmp += stack[i]
    if i % 2 == 0:
        if flag:
            right.append(tmp)
        else:
            left.append(tmp)
    else:
        if flag:
            left.append(tmp)
        else:
            right.append(tmp)
ans = 0
if flag:
    for i in range(len(right) - k - 1):
        ans = max(ans, right[i + k + 1] - left[i])
else:
    for i in range(len(right) - k):
        ans = max(ans, right[i + k] - left[i])
print(ans)

-tmp = 0 -now = 1 -for i in range(n): -    if s[i] == now: -        tmp += 1 -    else: +tmp = 1 +flag = True +for i in range(1, len(s)): +    if s[i] != s[i - 1]: -        now = 1 - now +    else: +        tmp += 1 -if len(stack) % 2 == 0: -    stack.append(0) -Acc = [0] * (len(stack) + 1) +left = [0] +right = [0] +tmp = 0 +if s[0] == 0: +    flag = False +    if len(stack) % 2 == 1: +        stack.append(0) +    if len(stack) // 2 <= k: +        print((len(s))) +        exit() +else: +    if len(stack) % 2 == 0: +        stack.append(0) +    if len(stack) // 2 <= k: +        print((len(s))) +        exit() -    Acc[i + 1] = Acc[i] + stack[i] +    tmp += stack[i] +    if i % 2 == 0: +        if flag: +            right.append(tmp) +        else: +            left.append(tmp) +    else: +        if flag: +            left.append(tmp) +        else: +            right.append(tmp) -for i in range(0, len(stack), 2): -    left = i -    right = min(i + k * 2 + 1, len(stack)) -    ans = max(ans, Acc[right] - Acc[left]) +if flag: +    for i in range(len(right) - k - 1): +        ans = max(ans, right[i + k + 1] - left[i]) +else: +    for i in range(len(right) - k): +        ans = max(ans, right[i + k] - left[i])