# しゃくとり法

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

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



j = 1

r = 0

t = []

for i in range(N):

    if S[i] == j:

        r += 1

    else:

        t.append(r)

        r = 1

        j ^= 1

t.append(r)

if j == 0:

    t.append(0)



if K >= (len(t) - 1) // 2:

    print((sum(t)))

else:

    result = sum(t[:2 * K + 1])

    j = result

    i = 2

    while i + 2 * K < len(t):

        j += t[i + 2 * K - 1] + t[i + 2 * K] - (t[i - 2] + t[i - 1])

        result = max(result, j)

        i += 2

    print(result)

# 累積和

from sys import exit



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

S = eval(input())



p = '1'

count = 0

cs = []

for c in S:

  if c != p:

    cs.append(count)

    p = c

    count = 1

  else:

    count += 1

cs.append(count)

if p == '0':

  cs.append(0)



if len(cs) < 2 * K:

  print(N)

  exit()



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

  cs[i] += cs[i - 1]



result = cs[2 * K]

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

  t = cs[2 * K + i] - cs[i - 1]

  if t > result:

    result = t

print(result)

# しゃくとり法
N, K = list(map(int, input().split()))
S = list(map(int, eval(input())))
j = 1
r = 0
t = []
for i in range(N):
    if S[i] == j:
        r += 1
    else:
        t.append(r)
        r = 1
        j ^= 1
t.append(r)
if j == 0:
    t.append(0)
if K >= (len(t) - 1) // 2:
    print((sum(t)))
else:
    result = sum(t[: 2 * K + 1])
    j = result
    i = 2
    while i + 2 * K < len(t):
        j += t[i + 2 * K - 1] + t[i + 2 * K] - (t[i - 2] + t[i - 1])
        result = max(result, j)
        i += 2
    print(result)

# 累積和
from sys import exit

N, K = list(map(int, input().split()))
S = eval(input())
p = "1"
count = 0
cs = []
for c in S:
    if c != p:
        cs.append(count)
        p = c
        count = 1
    else:
        count += 1
cs.append(count)
if p == "0":
    cs.append(0)
if len(cs) < 2 * K:
    print(N)
    exit()
for i in range(1, len(cs)):
    cs[i] += cs[i - 1]
result = cs[2 * K]
for i in range(2, len(cs) - 2 * K, 2):
    t = cs[2 * K + i] - cs[i - 1]
    if t > result:
        result = t
print(result)

-# しゃくとり法 +# 累積和 +from sys import exit + -S = list(map(int, eval(input()))) -j = 1 -r = 0 -t = [] -for i in range(N): -    if S[i] == j: -        r += 1 +S = eval(input()) +p = "1" +count = 0 +cs = [] +for c in S: +    if c != p: +        cs.append(count) +        p = c +        count = 1 -        t.append(r) -        r = 1 -        j ^= 1 -t.append(r) -if j == 0: -    t.append(0) -if K >= (len(t) - 1) // 2: -    print((sum(t))) -else: -    result = sum(t[: 2 * K + 1]) -    j = result -    i = 2 -    while i + 2 * K < len(t): -        j += t[i + 2 * K - 1] + t[i + 2 * K] - (t[i - 2] + t[i - 1]) -        result = max(result, j) -        i += 2 -    print(result) +        count += 1 +cs.append(count) +if p == "0": +    cs.append(0) +if len(cs) < 2 * K: +    print(N) +    exit() +for i in range(1, len(cs)): +    cs[i] += cs[i - 1] +result = cs[2 * K] +for i in range(2, len(cs) - 2 * K, 2): +    t = cs[2 * K + i] - cs[i - 1] +    if t > result: +        result = t +print(result)