from collections import deque





def nextj(n):

    while S[n] == '0':

        n += 1

        if n == N:

            return N

    q.appendleft(n)

    while S[n] == '1':

        n += 1

        if n == N:

            return N

    return n





def init(n):

    while S[n] == '1':

        n += 1

        if n == N:

            return N

    return n





def calc():

    q.appendleft(0)

    ans = 0

    j = init(0)

    if j == N:

        return N

    for _ in range(K - 1):

        j = nextj(j)

        if j == N:

            return N

    while True:

        j = nextj(j)

        ans = max(ans, j - q.pop())

        if j == N:

            return ans





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

S = eval(input())

q = deque()

print((calc()))

from collections import deque





def calc():

    q.appendleft(0)

    ans = 0

    d = '1'

    kc = 0

    for i, c in enumerate(S):

        if c != d:

            d = c

            if c == '0':

                if kc == K:

                    ans = max(ans, i - q.pop())

                else:

                    kc += 1

            else:

                q.appendleft(i)

    return max(ans, N - q.pop())





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

S = eval(input())

q = deque()

print((calc()))

from collections import deque


def nextj(n):
    while S[n] == "0":
        n += 1
        if n == N:
            return N
    q.appendleft(n)
    while S[n] == "1":
        n += 1
        if n == N:
            return N
    return n


def init(n):
    while S[n] == "1":
        n += 1
        if n == N:
            return N
    return n


def calc():
    q.appendleft(0)
    ans = 0
    j = init(0)
    if j == N:
        return N
    for _ in range(K - 1):
        j = nextj(j)
        if j == N:
            return N
    while True:
        j = nextj(j)
        ans = max(ans, j - q.pop())
        if j == N:
            return ans


N, K = list(map(int, input().split()))
S = eval(input())
q = deque()
print((calc()))

from collections import deque


def calc():
    q.appendleft(0)
    ans = 0
    d = "1"
    kc = 0
    for i, c in enumerate(S):
        if c != d:
            d = c
            if c == "0":
                if kc == K:
                    ans = max(ans, i - q.pop())
                else:
                    kc += 1
            else:
                q.appendleft(i)
    return max(ans, N - q.pop())


N, K = list(map(int, input().split()))
S = eval(input())
q = deque()
print((calc()))

- - -def nextj(n): -    while S[n] == "0": -        n += 1 -        if n == N: -            return N -    q.appendleft(n) -    while S[n] == "1": -        n += 1 -        if n == N: -            return N -    return n - - -def init(n): -    while S[n] == "1": -        n += 1 -        if n == N: -            return N -    return n -    j = init(0) -    if j == N: -        return N -    for _ in range(K - 1): -        j = nextj(j) -        if j == N: -            return N -    while True: -        j = nextj(j) -        ans = max(ans, j - q.pop()) -        if j == N: -            return ans +    d = "1" +    kc = 0 +    for i, c in enumerate(S): +        if c != d: +            d = c +            if c == "0": +                if kc == K: +                    ans = max(ans, i - q.pop()) +                else: +                    kc += 1 +            else: +                q.appendleft(i) +    return max(ans, N - q.pop())