def resolve():

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

    S = eval(input())

    seq = []

    cnt = 0

    for i in range(len(S)):

        if i == N-1 or S[i] != S[i+1]:

            seq.append([cnt+1, S[i]])

            cnt = 0

        else:

            cnt += 1

    #print(seq)

    left = 0

    right = 0

    maxlen = 0

    val = 0

    n_rev = 0

    for left in range(0, len(seq)):

        while (right < len(seq) and (n_rev < K or seq[right][1]=="1")):

            #print("left={}, right={}, n_rev={}".format(left, right, n_rev))

            cnt, state = seq[right]

            val += cnt

            if state == "0":

                n_rev += 1

            right += 1

        maxlen = max(maxlen, val)

        cnt, state = seq[left]

        val -= cnt

        if state == "0":

            n_rev -= 1

        if left == right:

            right += 1

    print(maxlen)

    



if '__main__' == __name__:

    resolve()
# 累積和による解法

def resolve():

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

    S = eval(input())

    seq = []

    cnt = 0

    if S[0] != "1":

        seq.append(0)

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

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

            seq.append(cnt+1)

            cnt = 0

        else:

            cnt += 1

    seq.append(cnt+1)

    if S[-1] != "1":

        seq.append(0)

    #print(seq)



    cum = [0]

    cur = 0

    for c in seq:

        cur += c

        cum.append(cur)

    #print(cum)

    

    maxlen = len(S) if len(cum) <= (2*K+1) else 0

    for i in range(0, len(cum)-(2*K+1), 2):

        l = cum[i+(2*K+1)] - cum[i]

        maxlen = max(maxlen, l)

    print(maxlen)

    



if '__main__' == __name__:

    resolve()
def resolve():
    N, K = list(map(int, input().split()))
    S = eval(input())
    seq = []
    cnt = 0
    for i in range(len(S)):
        if i == N - 1 or S[i] != S[i + 1]:
            seq.append([cnt + 1, S[i]])
            cnt = 0
        else:
            cnt += 1
    # print(seq)
    left = 0
    right = 0
    maxlen = 0
    val = 0
    n_rev = 0
    for left in range(0, len(seq)):
        while right < len(seq) and (n_rev < K or seq[right][1] == "1"):
            # print("left={}, right={}, n_rev={}".format(left, right, n_rev))
            cnt, state = seq[right]
            val += cnt
            if state == "0":
                n_rev += 1
            right += 1
        maxlen = max(maxlen, val)
        cnt, state = seq[left]
        val -= cnt
        if state == "0":
            n_rev -= 1
        if left == right:
            right += 1
    print(maxlen)


if "__main__" == __name__:
    resolve()

# 累積和による解法
def resolve():
    N, K = list(map(int, input().split()))
    S = eval(input())
    seq = []
    cnt = 0
    if S[0] != "1":
        seq.append(0)
    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            seq.append(cnt + 1)
            cnt = 0
        else:
            cnt += 1
    seq.append(cnt + 1)
    if S[-1] != "1":
        seq.append(0)
    # print(seq)
    cum = [0]
    cur = 0
    for c in seq:
        cur += c
        cum.append(cur)
    # print(cum)
    maxlen = len(S) if len(cum) <= (2 * K + 1) else 0
    for i in range(0, len(cum) - (2 * K + 1), 2):
        l = cum[i + (2 * K + 1)] - cum[i]
        maxlen = max(maxlen, l)
    print(maxlen)


if "__main__" == __name__:
    resolve()

+# 累積和による解法 -    for i in range(len(S)): -        if i == N - 1 or S[i] != S[i + 1]: -            seq.append([cnt + 1, S[i]]) +    if S[0] != "1": +        seq.append(0) +    for i in range(len(S) - 1): +        if S[i] != S[i + 1]: +            seq.append(cnt + 1) +    seq.append(cnt + 1) +    if S[-1] != "1": +        seq.append(0) -    left = 0 -    right = 0 -    maxlen = 0 -    val = 0 -    n_rev = 0 -    for left in range(0, len(seq)): -        while right < len(seq) and (n_rev < K or seq[right][1] == "1"): -            # print("left={}, right={}, n_rev={}".format(left, right, n_rev)) -            cnt, state = seq[right] -            val += cnt -            if state == "0": -                n_rev += 1 -            right += 1 -        maxlen = max(maxlen, val) -        cnt, state = seq[left] -        val -= cnt -        if state == "0": -            n_rev -= 1 -        if left == right: -            right += 1 +    cum = [0] +    cur = 0 +    for c in seq: +        cur += c +        cum.append(cur) +    # print(cum) +    maxlen = len(S) if len(cum) <= (2 * K + 1) else 0 +    for i in range(0, len(cum) - (2 * K + 1), 2): +        l = cum[i + (2 * K + 1)] - cum[i] +        maxlen = max(maxlen, l)