from itertools import accumulate



def length(S):

    cnt = 1

    A = []

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

        if S[i] == S[i+1]:

            cnt += 1

        else:

            A.append(cnt)

            cnt = 1

    else:

        A.append(cnt)



    return A



def main():

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

    S = eval(input())

    lens = length(S)

    A = [0] + list(accumulate(lens))

    ans = 0

    if S[0] == '0':

        A = [0] + A

        for i in range(1,len(A)+1,2):

            right = i + 2 * K

            if right >= len(A):

                right = len(A) - 1

            tmp = A[right] - A[i-1]

            ans = max(ans, tmp)

    else:

        for i in range(1,len(A)+1,2):

            right = i + 2 * K

            if right >= len(A):

                right = len(A) - 1

            tmp = A[right] - A[i-1]

            ans = max(ans, tmp)



    print(ans)







if __name__ == "__main__":

    main()
from itertools import accumulate



def runlength(S):

    cnt = 1

    A = []

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

        if S[i] == S[i+1]:

            cnt += 1

        else:

            A.append(cnt)

            cnt = 1

    else:

        A.append(cnt)



    return A





def main():

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

    S = eval(input())

    T = []

    prev = '1'

    cnt = 0

    for c in S:

        if prev == c:

            cnt += 1

        else:

            T.append(cnt)

            cnt = 1

        prev = c

    

    T.append(cnt)    

    if prev == '0':

        T.append(0)



    w = 2 * K + 1

    if len(T) <= w:

        print(N)

        exit()



    acc = [0] + list(accumulate(T))

    ans = 0

    for i in range(0, len(T) - w + 1, 2):

        ans = max(ans, acc[i+w] -acc[i])



    print(ans)



if __name__ == "__main__":

    main()
from itertools import accumulate


def length(S):
    cnt = 1
    A = []
    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            cnt += 1
        else:
            A.append(cnt)
            cnt = 1
    else:
        A.append(cnt)
    return A


def main():
    N, K = list(map(int, input().split()))
    S = eval(input())
    lens = length(S)
    A = [0] + list(accumulate(lens))
    ans = 0
    if S[0] == "0":
        A = [0] + A
        for i in range(1, len(A) + 1, 2):
            right = i + 2 * K
            if right >= len(A):
                right = len(A) - 1
            tmp = A[right] - A[i - 1]
            ans = max(ans, tmp)
    else:
        for i in range(1, len(A) + 1, 2):
            right = i + 2 * K
            if right >= len(A):
                right = len(A) - 1
            tmp = A[right] - A[i - 1]
            ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    main()

from itertools import accumulate


def runlength(S):
    cnt = 1
    A = []
    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            cnt += 1
        else:
            A.append(cnt)
            cnt = 1
    else:
        A.append(cnt)
    return A


def main():
    N, K = list(map(int, input().split()))
    S = eval(input())
    T = []
    prev = "1"
    cnt = 0
    for c in S:
        if prev == c:
            cnt += 1
        else:
            T.append(cnt)
            cnt = 1
        prev = c
    T.append(cnt)
    if prev == "0":
        T.append(0)
    w = 2 * K + 1
    if len(T) <= w:
        print(N)
        exit()
    acc = [0] + list(accumulate(T))
    ans = 0
    for i in range(0, len(T) - w + 1, 2):
        ans = max(ans, acc[i + w] - acc[i])
    print(ans)


if __name__ == "__main__":
    main()

-def length(S): +def runlength(S): -    lens = length(S) -    A = [0] + list(accumulate(lens)) +    T = [] +    prev = "1" +    cnt = 0 +    for c in S: +        if prev == c: +            cnt += 1 +        else: +            T.append(cnt) +            cnt = 1 +        prev = c +    T.append(cnt) +    if prev == "0": +        T.append(0) +    w = 2 * K + 1 +    if len(T) <= w: +        print(N) +        exit() +    acc = [0] + list(accumulate(T)) -    if S[0] == "0": -        A = [0] + A -        for i in range(1, len(A) + 1, 2): -            right = i + 2 * K -            if right >= len(A): -                right = len(A) - 1 -            tmp = A[right] - A[i - 1] -            ans = max(ans, tmp) -    else: -        for i in range(1, len(A) + 1, 2): -            right = i + 2 * K -            if right >= len(A): -                right = len(A) - 1 -            tmp = A[right] - A[i - 1] -            ans = max(ans, tmp) +    for i in range(0, len(T) - w + 1, 2): +        ans = max(ans, acc[i + w] - acc[i])