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

n = [int(i) for i in list(eval(input()))]

rem = n[0]

s = [1]

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

    if n[i] == rem:

        s[-1] += 1

    else:

        s.append(1)

        rem = n[i]



imax = 0

sum_ = 0

r = 0

if n[0] == 0:

    s.insert(0, 0)



for l in range(len(s)):

    sum_ += s[l]

    if l % 2 == 1 and l - r > k * 2:

        r += 2

        sum_ -= s[r-2] + s[r-1]

    if sum_ > imax:

        imax = sum_



print(imax)
n, k = [int(i) for i in input().split()]

s = [int(i) for i in eval(input())]



p = []

counter = 1

if s[0] == 0:

    p.append(0)

for i in range(1, n):

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

        counter += 1

    else:

        p.append(counter)

        counter = 1

p.append(counter)



l = p[0::2] + [0, 0]

r = p[1::2]



counter = sum(r[:k]) + sum(l[:k+1])

imax = counter

for i in range(k, len(r)):

    counter += l[i+1] + r[i]

    counter -= l[i-k] + r[i-k]

    if counter > imax:

        imax = counter



print(imax)
_, k = list(map(int, input().split()))
n = [int(i) for i in list(eval(input()))]
rem = n[0]
s = [1]
for i in range(1, len(n)):
    if n[i] == rem:
        s[-1] += 1
    else:
        s.append(1)
        rem = n[i]
imax = 0
sum_ = 0
r = 0
if n[0] == 0:
    s.insert(0, 0)
for l in range(len(s)):
    sum_ += s[l]
    if l % 2 == 1 and l - r > k * 2:
        r += 2
        sum_ -= s[r - 2] + s[r - 1]
    if sum_ > imax:
        imax = sum_
print(imax)

n, k = [int(i) for i in input().split()]
s = [int(i) for i in eval(input())]
p = []
counter = 1
if s[0] == 0:
    p.append(0)
for i in range(1, n):
    if s[i] == s[i - 1]:
        counter += 1
    else:
        p.append(counter)
        counter = 1
p.append(counter)
l = p[0::2] + [0, 0]
r = p[1::2]
counter = sum(r[:k]) + sum(l[: k + 1])
imax = counter
for i in range(k, len(r)):
    counter += l[i + 1] + r[i]
    counter -= l[i - k] + r[i - k]
    if counter > imax:
        imax = counter
print(imax)

-_, k = list(map(int, input().split())) -n = [int(i) for i in list(eval(input()))] -rem = n[0] -s = [1] -for i in range(1, len(n)): -    if n[i] == rem: -        s[-1] += 1 +n, k = [int(i) for i in input().split()] +s = [int(i) for i in eval(input())] +p = [] +counter = 1 +if s[0] == 0: +    p.append(0) +for i in range(1, n): +    if s[i] == s[i - 1]: +        counter += 1 -        s.append(1) -        rem = n[i] -imax = 0 -sum_ = 0 -r = 0 -if n[0] == 0: -    s.insert(0, 0) -for l in range(len(s)): -    sum_ += s[l] -    if l % 2 == 1 and l - r > k * 2: -        r += 2 -        sum_ -= s[r - 2] + s[r - 1] -    if sum_ > imax: -        imax = sum_ +        p.append(counter) +        counter = 1 +p.append(counter) +l = p[0::2] + [0, 0] +r = p[1::2] +counter = sum(r[:k]) + sum(l[: k + 1]) +imax = counter +for i in range(k, len(r)): +    counter += l[i + 1] + r[i] +    counter -= l[i - k] + r[i - k] +    if counter > imax: +        imax = counter