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

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



# 0 ,1 のまとまりを作る

sum01 = []

pre = 1

cnt = 0

# 111010

# 001010

for i, e in enumerate(list):

    if e != pre:

        sum01.append(cnt)

        cnt = 1

        pre = e

    else:

        cnt += 1

if cnt != 0:

    sum01.append(cnt)



if len(sum01) % 2 == 1:

    sum01.append(0)



# print(sum01)

Add = 2 * k + 1

ruiseki = [0]

for i, e in enumerate(sum01):

    ruiseki.append(ruiseki[i] + sum01[i])



# print(ruiseki)

answer = 0

for i in range(0, len(sum01), 2):

    left = i

    right = min(i + Add, len(sum01))

    temp = ruiseki[right] - ruiseki[left]

    answer = max(temp, answer)



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

S_list = ['0'] + list(eval(input())) + ['-1']



s_count_list =[]



cnt = 1

for i in range(1,N+2) :

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

        cnt +=1

    else:

        s_count_list.append(cnt)

        cnt = 1

if S_list[1] == '0':

    s_count_list[0] = s_count_list[0] -1

    s_count_list.insert(0,0)

else:

    s_count_list.pop(0)



ruisekiwa = [0]

for i,s in enumerate(s_count_list):

    ruisekiwa.append(ruisekiwa[i] + s)



if len(ruisekiwa) %2 ==0:

    ruisekiwa.append(0)



answer =  1

#print(s_count_list)

#Jjkprint(ruisekiwa)

for i in range(0,len(s_count_list),2):

    left = i

    right = min((i + (2 * K) + 1),len(s_count_list))

    #print(left,right)

    #print(ruisekiwa[right])

    tmp = ruisekiwa[right] - ruisekiwa[left]

    answer = max(tmp,answer)



print(answer)







q, k = list(map(int, input().split()))
list = [int(i) for i in eval(input())]
# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)
if len(sum01) % 2 == 1:
    sum01.append(0)
# print(sum01)
Add = 2 * k + 1
ruiseki = [0]
for i, e in enumerate(sum01):
    ruiseki.append(ruiseki[i] + sum01[i])
# print(ruiseki)
answer = 0
for i in range(0, len(sum01), 2):
    left = i
    right = min(i + Add, len(sum01))
    temp = ruiseki[right] - ruiseki[left]
    answer = max(temp, answer)
print(answer)

N, K = list(map(int, input().split()))
S_list = ["0"] + list(eval(input())) + ["-1"]
s_count_list = []
cnt = 1
for i in range(1, N + 2):
    if S_list[i] == S_list[i - 1]:
        cnt += 1
    else:
        s_count_list.append(cnt)
        cnt = 1
if S_list[1] == "0":
    s_count_list[0] = s_count_list[0] - 1
    s_count_list.insert(0, 0)
else:
    s_count_list.pop(0)
ruisekiwa = [0]
for i, s in enumerate(s_count_list):
    ruisekiwa.append(ruisekiwa[i] + s)
if len(ruisekiwa) % 2 == 0:
    ruisekiwa.append(0)
answer = 1
# print(s_count_list)
# Jjkprint(ruisekiwa)
for i in range(0, len(s_count_list), 2):
    left = i
    right = min((i + (2 * K) + 1), len(s_count_list))
    # print(left,right)
    # print(ruisekiwa[right])
    tmp = ruisekiwa[right] - ruisekiwa[left]
    answer = max(tmp, answer)
print(answer)

-q, k = list(map(int, input().split())) -list = [int(i) for i in eval(input())] -# 0 ,1 のまとまりを作る -sum01 = [] -pre = 1 -cnt = 0 -# 111010 -# 001010 -for i, e in enumerate(list): -    if e != pre: -        sum01.append(cnt) +N, K = list(map(int, input().split())) +S_list = ["0"] + list(eval(input())) + ["-1"] +s_count_list = [] +cnt = 1 +for i in range(1, N + 2): +    if S_list[i] == S_list[i - 1]: +        cnt += 1 +    else: +        s_count_list.append(cnt) -        pre = e -    else: -        cnt += 1 -if cnt != 0: -    sum01.append(cnt) -if len(sum01) % 2 == 1: -    sum01.append(0) -# print(sum01) -Add = 2 * k + 1 -ruiseki = [0] -for i, e in enumerate(sum01): -    ruiseki.append(ruiseki[i] + sum01[i]) -# print(ruiseki) -answer = 0 -for i in range(0, len(sum01), 2): +if S_list[1] == "0": +    s_count_list[0] = s_count_list[0] - 1 +    s_count_list.insert(0, 0) +else: +    s_count_list.pop(0) +ruisekiwa = [0] +for i, s in enumerate(s_count_list): +    ruisekiwa.append(ruisekiwa[i] + s) +if len(ruisekiwa) % 2 == 0: +    ruisekiwa.append(0) +answer = 1 +# print(s_count_list) +# Jjkprint(ruisekiwa) +for i in range(0, len(s_count_list), 2): -    right = min(i + Add, len(sum01)) -    temp = ruiseki[right] - ruiseki[left] -    answer = max(temp, answer) +    right = min((i + (2 * K) + 1), len(s_count_list)) +    # print(left,right) +    # print(ruisekiwa[right]) +    tmp = ruisekiwa[right] - ruisekiwa[left] +    answer = max(tmp, answer)