import numpy as np



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

S = eval(input())



l = [[], []]

ans = []

k = [int(s) for s in S]

if k[0] == 0:

    l[1].append(0)

v0 = 1 if k[0] == 0 else 0

v1 = 1 if k[0] == 1 else 0

for i in range(1, N):

    if (k[i]==0) & (k[i-1]==0):

        v0 += 1

    elif (k[i]==1) & (k[i-1]==0):

        l[0].append(v0)

        v0 = 0

        v1 += 1

    elif (k[i]==0) & (k[i-1]==1):

        l[1].append(v1)

        v0 += 1

        v1 = 0 

    else:

        v1 += 1

        

for i, v in enumerate([v0, v1]):

    if v > 0:

        l[i].append(v)

        

if k[0] == 0:

    l[1].append(0)



if len(l[0]) <= K:

    print(N)



else:

    l[0].extend(np.repeat(0,K+1))

    l[1].extend(np.repeat(0,K+1))

    a = sum(l[0][:K]) + sum(l[1][:K+1])

    ans.append(a)

    for i in range(1, len(l[0])-K-1):

        a -= l[0][i-1] + l[1][i-1]

        a += l[0][i+K-1] + l[1][i+K]

        ans.append(a)

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

S = eval(input())

 

l = [[], []]

ans = []

k = [int(s) for s in S]

if k[0] == 0:

    l[1].append(0)

v0 = 1 if k[0] == 0 else 0

v1 = 1 if k[0] == 1 else 0

for i in range(1, N):

    if (k[i]==0) & (k[i-1]==0):

        v0 += 1

    elif (k[i]==1) & (k[i-1]==0):

        l[0].append(v0)

        v0 = 0

        v1 += 1

    elif (k[i]==0) & (k[i-1]==1):

        l[1].append(v1)

        v0 += 1

        v1 = 0 

    else:

        v1 += 1

        

for i, v in enumerate([v0, v1]):

    if v > 0:

        l[i].append(v)

        

if k[0] == 0:

    l[1].append(0)

    

l[0] += [0]*(K+1)

l[1] += [0]*(K+1)

a = sum(l[0][:K]) + sum(l[1][:K+1])

ans.append(a)

for i in range(1, len(l[0])-K-1):

    a -= l[0][i-1] + l[1][i-1]

    a += l[0][i+K-1] + l[1][i+K]

    ans.append(a)

print((max(ans)))
import numpy as np

N, K = list(map(int, input().split()))
S = eval(input())
l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
    l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i] == 0) & (k[i - 1] == 0):
        v0 += 1
    elif (k[i] == 1) & (k[i - 1] == 0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i] == 0) & (k[i - 1] == 1):
        l[1].append(v1)
        v0 += 1
        v1 = 0
    else:
        v1 += 1
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)
if k[0] == 0:
    l[1].append(0)
if len(l[0]) <= K:
    print(N)
else:
    l[0].extend(np.repeat(0, K + 1))
    l[1].extend(np.repeat(0, K + 1))
    a = sum(l[0][:K]) + sum(l[1][: K + 1])
    ans.append(a)
    for i in range(1, len(l[0]) - K - 1):
        a -= l[0][i - 1] + l[1][i - 1]
        a += l[0][i + K - 1] + l[1][i + K]
        ans.append(a)
    print((max(ans)))

N, K = list(map(int, input().split()))
S = eval(input())
l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
    l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i] == 0) & (k[i - 1] == 0):
        v0 += 1
    elif (k[i] == 1) & (k[i - 1] == 0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i] == 0) & (k[i - 1] == 1):
        l[1].append(v1)
        v0 += 1
        v1 = 0
    else:
        v1 += 1
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)
if k[0] == 0:
    l[1].append(0)
l[0] += [0] * (K + 1)
l[1] += [0] * (K + 1)
a = sum(l[0][:K]) + sum(l[1][: K + 1])
ans.append(a)
for i in range(1, len(l[0]) - K - 1):
    a -= l[0][i - 1] + l[1][i - 1]
    a += l[0][i + K - 1] + l[1][i + K]
    ans.append(a)
print((max(ans)))

-import numpy as np - -if len(l[0]) <= K: -    print(N) -else: -    l[0].extend(np.repeat(0, K + 1)) -    l[1].extend(np.repeat(0, K + 1)) -    a = sum(l[0][:K]) + sum(l[1][: K + 1]) +l[0] += [0] * (K + 1) +l[1] += [0] * (K + 1) +a = sum(l[0][:K]) + sum(l[1][: K + 1]) +ans.append(a) +for i in range(1, len(l[0]) - K - 1): +    a -= l[0][i - 1] + l[1][i - 1] +    a += l[0][i + K - 1] + l[1][i + K] -    for i in range(1, len(l[0]) - K - 1): -        a -= l[0][i - 1] + l[1][i - 1] -        a += l[0][i + K - 1] + l[1][i + K] -        ans.append(a) -    print((max(ans))) +print((max(ans)))