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

s = list(eval(input()))



cnt_list = []

i = 0

if s[0] == "0":

    key = "0"

else:

    key = "1"

last = 0

while i < N:

    j = i

    tmp = 1

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

        if s[j] == key:

            tmp += 1

            if j == N - 1:

                last = 1

        else:

            break



    cnt_list.append([int(key), tmp])



    if key == "0":

        key = "1"

    else:

        key = "0"

    i = max(j, i + 1)

    if last:

        break



cnt = K

i = 0

tmp = 0

while cnt > 0 and i < len(cnt_list):

    tmp += cnt_list[i][1]

    if cnt_list[i][0] == 0:

        cnt -= 1

    i += 1



if i < len(cnt_list):

    tmp += cnt_list[i][1]

    i += 1



anslist = []

anslist.append(tmp)



start = 0

while i < len(cnt_list) and start < len(cnt_list):

    if cnt_list[start][0] == 1:

        tmp -= cnt_list[start][1]

        if start + 1 < len(cnt_list):

            tmp -= cnt_list[start + 1][1]

        start += 2

    else:

        tmp -= cnt_list[start][1]

        start += 1



    if cnt_list[i][0] == 0:

        tmp += cnt_list[i][1]

        if i + 1 < len(cnt_list):

            tmp += cnt_list[i + 1][1]

        i += 2

    else:

        tmp += cnt_list[i][1]

        i += 1

    anslist.append(tmp)



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

s = list(eval(input()))



cnt = 1

cntlist = []

for i in range(1, N):

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

        cntlist.append(cnt)

        cnt = 1

    else:

        cnt += 1



cntlist.append(cnt)

if s[0] == "0":

    cntlist = [0] + cntlist



ans = 0

for i in range(2 * K + 1):

    if i >= len(cntlist):

        break

    ans += cntlist[i]

anslist = [ans]

s = 0

g = 2 * K + 1

while g < len(cntlist):

    ans -= cntlist[s]

    ans -= cntlist[s + 1]

    s += 2

    ans += cntlist[g]

    g += 1

    if g >= len(cntlist):

        anslist.append(ans)

        break

    ans += cntlist[g]

    g += 1

    anslist.append(ans)



print((max(anslist)))
N, K = list(map(int, input().split()))
s = list(eval(input()))
cnt_list = []
i = 0
if s[0] == "0":
    key = "0"
else:
    key = "1"
last = 0
while i < N:
    j = i
    tmp = 1
    for j in range(i + 1, N):
        if s[j] == key:
            tmp += 1
            if j == N - 1:
                last = 1
        else:
            break
    cnt_list.append([int(key), tmp])
    if key == "0":
        key = "1"
    else:
        key = "0"
    i = max(j, i + 1)
    if last:
        break
cnt = K
i = 0
tmp = 0
while cnt > 0 and i < len(cnt_list):
    tmp += cnt_list[i][1]
    if cnt_list[i][0] == 0:
        cnt -= 1
    i += 1
if i < len(cnt_list):
    tmp += cnt_list[i][1]
    i += 1
anslist = []
anslist.append(tmp)
start = 0
while i < len(cnt_list) and start < len(cnt_list):
    if cnt_list[start][0] == 1:
        tmp -= cnt_list[start][1]
        if start + 1 < len(cnt_list):
            tmp -= cnt_list[start + 1][1]
        start += 2
    else:
        tmp -= cnt_list[start][1]
        start += 1
    if cnt_list[i][0] == 0:
        tmp += cnt_list[i][1]
        if i + 1 < len(cnt_list):
            tmp += cnt_list[i + 1][1]
        i += 2
    else:
        tmp += cnt_list[i][1]
        i += 1
    anslist.append(tmp)
print((max(anslist)))

N, K = list(map(int, input().split()))
s = list(eval(input()))
cnt = 1
cntlist = []
for i in range(1, N):
    if s[i - 1] != s[i]:
        cntlist.append(cnt)
        cnt = 1
    else:
        cnt += 1
cntlist.append(cnt)
if s[0] == "0":
    cntlist = [0] + cntlist
ans = 0
for i in range(2 * K + 1):
    if i >= len(cntlist):
        break
    ans += cntlist[i]
anslist = [ans]
s = 0
g = 2 * K + 1
while g < len(cntlist):
    ans -= cntlist[s]
    ans -= cntlist[s + 1]
    s += 2
    ans += cntlist[g]
    g += 1
    if g >= len(cntlist):
        anslist.append(ans)
        break
    ans += cntlist[g]
    g += 1
    anslist.append(ans)
print((max(anslist)))

-cnt_list = [] -i = 0 +cnt = 1 +cntlist = [] +for i in range(1, N): +    if s[i - 1] != s[i]: +        cntlist.append(cnt) +        cnt = 1 +    else: +        cnt += 1 +cntlist.append(cnt) -    key = "0" -else: -    key = "1" -last = 0 -while i < N: -    j = i -    tmp = 1 -    for j in range(i + 1, N): -        if s[j] == key: -            tmp += 1 -            if j == N - 1: -                last = 1 -        else: -            break -    cnt_list.append([int(key), tmp]) -    if key == "0": -        key = "1" -    else: -        key = "0" -    i = max(j, i + 1) -    if last: +    cntlist = [0] + cntlist +ans = 0 +for i in range(2 * K + 1): +    if i >= len(cntlist): -cnt = K -i = 0 -tmp = 0 -while cnt > 0 and i < len(cnt_list): -    tmp += cnt_list[i][1] -    if cnt_list[i][0] == 0: -        cnt -= 1 -    i += 1 -if i < len(cnt_list): -    tmp += cnt_list[i][1] -    i += 1 -anslist = [] -anslist.append(tmp) -start = 0 -while i < len(cnt_list) and start < len(cnt_list): -    if cnt_list[start][0] == 1: -        tmp -= cnt_list[start][1] -        if start + 1 < len(cnt_list): -            tmp -= cnt_list[start + 1][1] -        start += 2 -    else: -        tmp -= cnt_list[start][1] -        start += 1 -    if cnt_list[i][0] == 0: -        tmp += cnt_list[i][1] -        if i + 1 < len(cnt_list): -            tmp += cnt_list[i + 1][1] -        i += 2 -    else: -        tmp += cnt_list[i][1] -        i += 1 -    anslist.append(tmp) +    ans += cntlist[i] +anslist = [ans] +s = 0 +g = 2 * K + 1 +while g < len(cntlist): +    ans -= cntlist[s] +    ans -= cntlist[s + 1] +    s += 2 +    ans += cntlist[g] +    g += 1 +    if g >= len(cntlist): +        anslist.append(ans) +        break +    ans += cntlist[g] +    g += 1 +    anslist.append(ans)