import itertools



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

s = eval(input())



before = s[0]

count = 1

lst = []

head = True if before == '1' else False

tail = True if s[-1] == '1' else False



for i in s[1:]:

    if i == before:

        count += 1

    else:

        lst.append(count)

        count = 1

        before = i

lst.append(count)



S = 0



lst1 = lst

if not head:

    S = sum(lst1[:2*k])

    lst1 = lst1[1:]

if not tail:

    S = max(S, sum(lst1[-2*k:]))

    lst1 = lst1[:-1]



lst1.insert(0,0)

accum_lst = list(itertools.accumulate(lst1))



#print('accum_lst :', accum_lst)

N = len(lst1)

if N <= 2*k + 1:

    S = max(S, accum_lst[-1])

else:

    K = 2*k+1

    for i in range(0, N-K, 2):

        S = max(S, accum_lst[i+K] - accum_lst[i])

        #print(S, accum_lst[i+K], accum_lst[i])



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

s = eval(input())



index_lst = []

num_lst = []

before = '-1'

for K, i in enumerate(s):

    if i != before:

        before = i

        index_lst.append(K)

        num_lst.append(int(i))

N = len(index_lst)

index_lst += [n] * (2*k+10)

#print('index_lst: ', index_lst)

#print('num_lst: ', num_lst)



S = 0

for i in range(N):

    if num_lst[i] == 0:

        S = max(S, index_lst[i+2*k] - index_lst[i])

    else:

        S = max(S, index_lst[i+2*k+1] - index_lst[i])

print(S)
import itertools

n, k = list(map(int, input().split()))
s = eval(input())
before = s[0]
count = 1
lst = []
head = True if before == "1" else False
tail = True if s[-1] == "1" else False
for i in s[1:]:
    if i == before:
        count += 1
    else:
        lst.append(count)
        count = 1
        before = i
lst.append(count)
S = 0
lst1 = lst
if not head:
    S = sum(lst1[: 2 * k])
    lst1 = lst1[1:]
if not tail:
    S = max(S, sum(lst1[-2 * k :]))
    lst1 = lst1[:-1]
lst1.insert(0, 0)
accum_lst = list(itertools.accumulate(lst1))
# print('accum_lst :', accum_lst)
N = len(lst1)
if N <= 2 * k + 1:
    S = max(S, accum_lst[-1])
else:
    K = 2 * k + 1
    for i in range(0, N - K, 2):
        S = max(S, accum_lst[i + K] - accum_lst[i])
        # print(S, accum_lst[i+K], accum_lst[i])
print(S)

n, k = list(map(int, input().split()))
s = eval(input())
index_lst = []
num_lst = []
before = "-1"
for K, i in enumerate(s):
    if i != before:
        before = i
        index_lst.append(K)
        num_lst.append(int(i))
N = len(index_lst)
index_lst += [n] * (2 * k + 10)
# print('index_lst: ', index_lst)
# print('num_lst: ', num_lst)
S = 0
for i in range(N):
    if num_lst[i] == 0:
        S = max(S, index_lst[i + 2 * k] - index_lst[i])
    else:
        S = max(S, index_lst[i + 2 * k + 1] - index_lst[i])
print(S)

-import itertools - -before = s[0] -count = 1 -lst = [] -head = True if before == "1" else False -tail = True if s[-1] == "1" else False -for i in s[1:]: -    if i == before: -        count += 1 +index_lst = [] +num_lst = [] +before = "-1" +for K, i in enumerate(s): +    if i != before: +        before = i +        index_lst.append(K) +        num_lst.append(int(i)) +N = len(index_lst) +index_lst += [n] * (2 * k + 10) +# print('index_lst: ', index_lst) +# print('num_lst: ', num_lst) +S = 0 +for i in range(N): +    if num_lst[i] == 0: +        S = max(S, index_lst[i + 2 * k] - index_lst[i]) -        lst.append(count) -        count = 1 -        before = i -lst.append(count) -S = 0 -lst1 = lst -if not head: -    S = sum(lst1[: 2 * k]) -    lst1 = lst1[1:] -if not tail: -    S = max(S, sum(lst1[-2 * k :])) -    lst1 = lst1[:-1] -lst1.insert(0, 0) -accum_lst = list(itertools.accumulate(lst1)) -# print('accum_lst :', accum_lst) -N = len(lst1) -if N <= 2 * k + 1: -    S = max(S, accum_lst[-1]) -else: -    K = 2 * k + 1 -    for i in range(0, N - K, 2): -        S = max(S, accum_lst[i + K] - accum_lst[i]) -        # print(S, accum_lst[i+K], accum_lst[i]) +        S = max(S, index_lst[i + 2 * k + 1] - index_lst[i])