def f_d():

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

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

    l, t, c = [], 1, 0

    for i in range(n):

        if s[i]==t:

            c += 1

        else:

            l.append(c)

            c, t = 1, t^1

    if c!=0:

        l.append(c)

    if len(l)%2==0:

        l.append(0)



    r, a = 2*k+1, 0

    li = ri = tmp = 0

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

        nli, nri = i, min(i+r, len(l))

        while li<nli:

            tmp -= l[li]

            li += 1

        while ri<nri:

            tmp += l[ri]

            ri += 1

        a = max(a, tmp)

    print(a)



if __name__ == "__main__":

    f_d()

def f_d():

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

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

    l, t, c = [], 1, 0

    for i in range(n):

        if s[i]==t:

            c += 1

        else:

            l.append(c)

            c, t = 1, t^1

    if c!=0:

        l.append(c)

    if len(l)%2==0:

        l.append(0)



    r, cs = 2*k, [l[0]]



    for i in range(1, len(l)):

        cs.append(cs[i-1]+l[i])

    a = cs[0]

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

        tmp = cs[min(i+r, len(l)-1)]-cs[i]+l[i]

        a = max(a, tmp)

    print(a)



if __name__ == "__main__":

    f_d()
def f_d():
    n, k = list(map(int, input().split()))
    (*s,) = list(map(int, list(eval(input()))))
    l, t, c = [], 1, 0
    for i in range(n):
        if s[i] == t:
            c += 1
        else:
            l.append(c)
            c, t = 1, t ^ 1
    if c != 0:
        l.append(c)
    if len(l) % 2 == 0:
        l.append(0)
    r, a = 2 * k + 1, 0
    li = ri = tmp = 0
    for i in range(0, len(l), 2):
        nli, nri = i, min(i + r, len(l))
        while li < nli:
            tmp -= l[li]
            li += 1
        while ri < nri:
            tmp += l[ri]
            ri += 1
        a = max(a, tmp)
    print(a)


if __name__ == "__main__":
    f_d()

def f_d():
    n, k = list(map(int, input().split()))
    (*s,) = list(map(int, list(eval(input()))))
    l, t, c = [], 1, 0
    for i in range(n):
        if s[i] == t:
            c += 1
        else:
            l.append(c)
            c, t = 1, t ^ 1
    if c != 0:
        l.append(c)
    if len(l) % 2 == 0:
        l.append(0)
    r, cs = 2 * k, [l[0]]
    for i in range(1, len(l)):
        cs.append(cs[i - 1] + l[i])
    a = cs[0]
    for i in range(0, len(l), 2):
        tmp = cs[min(i + r, len(l) - 1)] - cs[i] + l[i]
        a = max(a, tmp)
    print(a)


if __name__ == "__main__":
    f_d()

-    r, a = 2 * k + 1, 0 -    li = ri = tmp = 0 +    r, cs = 2 * k, [l[0]] +    for i in range(1, len(l)): +        cs.append(cs[i - 1] + l[i]) +    a = cs[0] -        nli, nri = i, min(i + r, len(l)) -        while li < nli: -            tmp -= l[li] -            li += 1 -        while ri < nri: -            tmp += l[ri] -            ri += 1 +        tmp = cs[min(i + r, len(l) - 1)] - cs[i] + l[i]