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

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

A = []

B = []

if S[0] == 1:

  A.append(0)

  B.append(1)

else:

  A.extend([0,1])

  B.extend([0,0])

  

for i in range(1,N):

  if S[i] == S[i-1]:

    if S[i] == 0:

      A[-1] += 1

    else:

      B[-1] += 1

  else:

    if S[i] == 0:

      A.append(1)

      B.append(0)

    else:

      A.append(0)

      B.append(1)

if B[-1] == 0:

  A.append(0)

  B.append(0)



M = len(A)

tmp = sum(A[0:2*K+1]) + sum(B[0:2*K+1])

ans = tmp

for i in range(2,M-2*K,2):

  tmp -= A[i-1] + B[i-2]

  tmp += A[i+2*K-1] + B[i+2*K]

  ans = max(ans,tmp)

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

S = eval(input())

array = []

count = 1

if S[0] == "0":

  array.append(0)

for i in range(N):

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

    array.append(count)

    count = 1

  elif S[i] == S[i+1]:

    count += 1

if S[-1] == "0":

  array.append(0)

M = len(array)

ans = sum(array[0:2*K+1])

tmp = ans

for l in range(2,M-2*K,2):

  tmp -= array[l-2] + array[l-1]

  tmp += array[l+2*K-1] + array[l+2*K]

  ans = max(ans,tmp)

print(ans)
N, K = list(map(int, input().split()))
S = list(map(int, list(eval(input()))))
A = []
B = []
if S[0] == 1:
    A.append(0)
    B.append(1)
else:
    A.extend([0, 1])
    B.extend([0, 0])
for i in range(1, N):
    if S[i] == S[i - 1]:
        if S[i] == 0:
            A[-1] += 1
        else:
            B[-1] += 1
    else:
        if S[i] == 0:
            A.append(1)
            B.append(0)
        else:
            A.append(0)
            B.append(1)
if B[-1] == 0:
    A.append(0)
    B.append(0)
M = len(A)
tmp = sum(A[0 : 2 * K + 1]) + sum(B[0 : 2 * K + 1])
ans = tmp
for i in range(2, M - 2 * K, 2):
    tmp -= A[i - 1] + B[i - 2]
    tmp += A[i + 2 * K - 1] + B[i + 2 * K]
    ans = max(ans, tmp)
print(ans)

N, K = list(map(int, input().split()))
S = eval(input())
array = []
count = 1
if S[0] == "0":
    array.append(0)
for i in range(N):
    if i + 1 == N or S[i] != S[i + 1]:
        array.append(count)
        count = 1
    elif S[i] == S[i + 1]:
        count += 1
if S[-1] == "0":
    array.append(0)
M = len(array)
ans = sum(array[0 : 2 * K + 1])
tmp = ans
for l in range(2, M - 2 * K, 2):
    tmp -= array[l - 2] + array[l - 1]
    tmp += array[l + 2 * K - 1] + array[l + 2 * K]
    ans = max(ans, tmp)
print(ans)

-S = list(map(int, list(eval(input())))) -A = [] -B = [] -if S[0] == 1: -    A.append(0) -    B.append(1) -else: -    A.extend([0, 1]) -    B.extend([0, 0]) -for i in range(1, N): -    if S[i] == S[i - 1]: -        if S[i] == 0: -            A[-1] += 1 -        else: -            B[-1] += 1 -    else: -        if S[i] == 0: -            A.append(1) -            B.append(0) -        else: -            A.append(0) -            B.append(1) -if B[-1] == 0: -    A.append(0) -    B.append(0) -M = len(A) -tmp = sum(A[0 : 2 * K + 1]) + sum(B[0 : 2 * K + 1]) -ans = tmp -for i in range(2, M - 2 * K, 2): -    tmp -= A[i - 1] + B[i - 2] -    tmp += A[i + 2 * K - 1] + B[i + 2 * K] +S = eval(input()) +array = [] +count = 1 +if S[0] == "0": +    array.append(0) +for i in range(N): +    if i + 1 == N or S[i] != S[i + 1]: +        array.append(count) +        count = 1 +    elif S[i] == S[i + 1]: +        count += 1 +if S[-1] == "0": +    array.append(0) +M = len(array) +ans = sum(array[0 : 2 * K + 1]) +tmp = ans +for l in range(2, M - 2 * K, 2): +    tmp -= array[l - 2] + array[l - 1] +    tmp += array[l + 2 * K - 1] + array[l + 2 * K]