# -*- coding: utf-8 -*-





def main(N, K, S):

    cnts = []

    now = 1

    cnt = 0

    for n in S:

        if now == int(n): 

            cnt += 1

        else:

            cnts.append(cnt)

            cnt = 1

            now = 1 - now

    if cnt != 0: cnts.append(cnt)



    if len(cnts) % 2 == 0: cnts.append(0)

    

    ans = 0

    Add = 2 * K + 1



    sums = [0]

    for c in cnts:

        sums.append(sums[-1] + c)



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

        left = i

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

        tmp = sums[right] - sums[left]



        ans = max(tmp, ans)

    print(ans)



if __name__ == "__main__":

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

    s = eval(input())

    main(n, k, s)

# -*- coding: utf-8 -*-

from itertools import accumulate





def main(N, K, S):

    cnts = []

    now = '1'

    cnt = 0

    for n in S:

        if now == n:

            cnt += 1

        else:

            cnts.append(cnt)

            cnt = 1

            now = n

    cnts.append(cnt)



    if now == '0': cnts.append(0)

    

    ans = 0

    Add = 2 * K + 1



    sums = [0] + list(accumulate(cnts))



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

        left = i

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

        tmp = sums[right] - sums[left]



        ans = max(tmp, ans)

    print(ans)



if __name__ == "__main__":

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

    s = eval(input())

    main(n, k, s)

# -*- coding: utf-8 -*-
def main(N, K, S):
    cnts = []
    now = 1
    cnt = 0
    for n in S:
        if now == int(n):
            cnt += 1
        else:
            cnts.append(cnt)
            cnt = 1
            now = 1 - now
    if cnt != 0:
        cnts.append(cnt)
    if len(cnts) % 2 == 0:
        cnts.append(0)
    ans = 0
    Add = 2 * K + 1
    sums = [0]
    for c in cnts:
        sums.append(sums[-1] + c)
    for i in range(0, len(cnts), 2):
        left = i
        right = min(i + Add, len(cnts))
        tmp = sums[right] - sums[left]
        ans = max(tmp, ans)
    print(ans)


if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    s = eval(input())
    main(n, k, s)

# -*- coding: utf-8 -*-
from itertools import accumulate


def main(N, K, S):
    cnts = []
    now = "1"
    cnt = 0
    for n in S:
        if now == n:
            cnt += 1
        else:
            cnts.append(cnt)
            cnt = 1
            now = n
    cnts.append(cnt)
    if now == "0":
        cnts.append(0)
    ans = 0
    Add = 2 * K + 1
    sums = [0] + list(accumulate(cnts))
    for i in range(0, len(cnts), 2):
        left = i
        right = min(i + Add, len(cnts))
        tmp = sums[right] - sums[left]
        ans = max(tmp, ans)
    print(ans)


if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    s = eval(input())
    main(n, k, s)

+from itertools import accumulate + + -    now = 1 +    now = "1" -        if now == int(n): +        if now == n: -            now = 1 - now -    if cnt != 0: -        cnts.append(cnt) -    if len(cnts) % 2 == 0: +            now = n +    cnts.append(cnt) +    if now == "0": -    sums = [0] -    for c in cnts: -        sums.append(sums[-1] + c) +    sums = [0] + list(accumulate(cnts))