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

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

s_list = list()

num = s[0]

temp_streak = 0

# temp_max = 0

# temp_sum = 0

[s_list.append(0) for i in range(1+s[0])]



for i in s:

    if i == num:

        temp_streak += 1

    else:

        s_list.append(temp_streak)

        temp_streak = 1

        num = i



s_list.append(temp_streak)

[s_list.append(0) for i in range(1+s[-1])]

# odd = len(s_list)%2

num_i = len(s_list) // 2 

# print(s_list)

temp_max = sum(s_list[0:min(k*2+1,len(s_list) + 1)])

temp_sum = temp_max

temp_max_debug = temp_max

# print(temp_max)

for i in range(1,max(num_i+1-k,1)):

    temp_sum = temp_sum - s_list[i*2-2] - s_list[i*2-1] + s_list[i*2+k*2-1] + s_list[i*2+k*2]

    temp_max = max(temp_max,temp_sum)

    # temp_max_debug = max(temp_max_debug,sum(s_list[i*2:i*2+k*2+1]))

print(temp_max)

# print(temp_max_debug)







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

s = eval(input())

ms = 0

ps = 0

temp = [0]

if s[0] == "0":

    temp.append(0)

for i in s:

    # print(i,ps,ms)

    if i == "0":

        ms += 1

        if ps:

            temp.append(ps)

            ps = 0

    else:

        ps += 1

        if ms:

            temp.append(ms)

            ms = 0

if ms:

    temp.append(ms)

else:

    temp.append(ps)

# print(temp)

temp.append(0)

for i in range(len(temp)-1):

    temp[i+1] += temp[i]

# print(temp)

ans = 0

if len(temp)-(2*k+1) <= 0:

    ans = temp[-1]

else:

    for i in range(0,len(temp)-(2*k+1),2):

        ans = max(ans,temp[i+2*k+1]-temp[i])

print(ans)
n, k = list(map(int, input().split()))
s = list(map(int, eval(input())))
s_list = list()
num = s[0]
temp_streak = 0
# temp_max = 0
# temp_sum = 0
[s_list.append(0) for i in range(1 + s[0])]
for i in s:
    if i == num:
        temp_streak += 1
    else:
        s_list.append(temp_streak)
        temp_streak = 1
        num = i
s_list.append(temp_streak)
[s_list.append(0) for i in range(1 + s[-1])]
# odd = len(s_list)%2
num_i = len(s_list) // 2
# print(s_list)
temp_max = sum(s_list[0 : min(k * 2 + 1, len(s_list) + 1)])
temp_sum = temp_max
temp_max_debug = temp_max
# print(temp_max)
for i in range(1, max(num_i + 1 - k, 1)):
    temp_sum = (
        temp_sum
        - s_list[i * 2 - 2]
        - s_list[i * 2 - 1]
        + s_list[i * 2 + k * 2 - 1]
        + s_list[i * 2 + k * 2]
    )
    temp_max = max(temp_max, temp_sum)
    # temp_max_debug = max(temp_max_debug,sum(s_list[i*2:i*2+k*2+1]))
print(temp_max)
# print(temp_max_debug)
# print(s_list)

n, k = list(map(int, input().split()))
s = eval(input())
ms = 0
ps = 0
temp = [0]
if s[0] == "0":
    temp.append(0)
for i in s:
    # print(i,ps,ms)
    if i == "0":
        ms += 1
        if ps:
            temp.append(ps)
            ps = 0
    else:
        ps += 1
        if ms:
            temp.append(ms)
            ms = 0
if ms:
    temp.append(ms)
else:
    temp.append(ps)
# print(temp)
temp.append(0)
for i in range(len(temp) - 1):
    temp[i + 1] += temp[i]
# print(temp)
ans = 0
if len(temp) - (2 * k + 1) <= 0:
    ans = temp[-1]
else:
    for i in range(0, len(temp) - (2 * k + 1), 2):
        ans = max(ans, temp[i + 2 * k + 1] - temp[i])
print(ans)

-s = list(map(int, eval(input()))) -s_list = list() -num = s[0] -temp_streak = 0 -# temp_max = 0 -# temp_sum = 0 -[s_list.append(0) for i in range(1 + s[0])] +s = eval(input()) +ms = 0 +ps = 0 +temp = [0] +if s[0] == "0": +    temp.append(0) -    if i == num: -        temp_streak += 1 +    # print(i,ps,ms) +    if i == "0": +        ms += 1 +        if ps: +            temp.append(ps) +            ps = 0 -        s_list.append(temp_streak) -        temp_streak = 1 -        num = i -s_list.append(temp_streak) -[s_list.append(0) for i in range(1 + s[-1])] -# odd = len(s_list)%2 -num_i = len(s_list) // 2 -# print(s_list) -temp_max = sum(s_list[0 : min(k * 2 + 1, len(s_list) + 1)]) -temp_sum = temp_max -temp_max_debug = temp_max -# print(temp_max) -for i in range(1, max(num_i + 1 - k, 1)): -    temp_sum = ( -        temp_sum -        - s_list[i * 2 - 2] -        - s_list[i * 2 - 1] -        + s_list[i * 2 + k * 2 - 1] -        + s_list[i * 2 + k * 2] -    ) -    temp_max = max(temp_max, temp_sum) -    # temp_max_debug = max(temp_max_debug,sum(s_list[i*2:i*2+k*2+1])) -print(temp_max) -# print(temp_max_debug) -# print(s_list) +        ps += 1 +        if ms: +            temp.append(ms) +            ms = 0 +if ms: +    temp.append(ms) +else: +    temp.append(ps) +# print(temp) +temp.append(0) +for i in range(len(temp) - 1): +    temp[i + 1] += temp[i] +# print(temp) +ans = 0 +if len(temp) - (2 * k + 1) <= 0: +    ans = temp[-1] +else: +    for i in range(0, len(temp) - (2 * k + 1), 2): +        ans = max(ans, temp[i + 2 * k + 1] - temp[i]) +print(ans)