import sys

stdin = sys.stdin 

ni = lambda: int(ns())

na = lambda: list(map(int, stdin.readline().split()))

ns = lambda: stdin.readline()



def Solve():

    N,K=na()

    S=[int(d) for d in eval(input())]

    l=[]

    N=len(S)

    if(S[0]==0):

        l.append(0)

    b=S[0]

    ct=1

    for i in S[1:]:

        if(b!=i):

            l.append(ct)

            ct=1

            b=i

        else:

            ct+=1

    l.append(ct)

    len_l=len(l)

    if(len_l//2 <= K):

        return sum(l)

    ans = res = sum(l[:2*K+1])

    

    if(len_l%2==0):

        l.append(0)

        len_l+=1

    g = K * 2 + 1

    for i in range(K*2+1,len_l-1,2):

        ans -= l[i-g] + l[i-g+1]

        ans += l[i] + l[1+i]

        if(res<ans):

            res=ans

    #print(S)

    #print(l)

    #print(len_l)

    return res



print((Solve()))
import sys

stdin = sys.stdin 

ni = lambda: int(ns())

na = lambda: list(map(int, stdin.readline().split()))

ns = lambda: stdin.readline()



def Solve():

    N,K=na()

    S=eval(input())

    l=[]

    N=len(S)

    #print(len(S))

    if(S[0]=="0"):

        #print("00")

        l.append(0)

    t=S[0]

    ct=1

    #print("aa")

    #print(S)

    #print(S[0],S[1],S[2])

    for b in S[1:]:

        #print(b)

        if(t!=b):

            l.append(ct)

            ct=1

            t=b

        else:

            ct+=1

    #print("bb")

    l.append(ct)

    len_l=len(l)

    if(len_l//2 <= K):

        return sum(l)

    ans = res = sum(l[:2*K+1])

    

    if(len_l%2==0):

        l.append(0)

        len_l+=1

    g = K * 2 + 1

    for i in range(K*2+1,len_l-1,2):

        ans -= l[i-g] + l[i-g+1]

        ans += l[i] + l[1+i]

        if(res<ans):

            res=ans

    #print(S)

    #print(l)

    #print(len_l)

    return res



print((Solve()))
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


def Solve():
    N, K = na()
    S = [int(d) for d in eval(input())]
    l = []
    N = len(S)
    if S[0] == 0:
        l.append(0)
    b = S[0]
    ct = 1
    for i in S[1:]:
        if b != i:
            l.append(ct)
            ct = 1
            b = i
        else:
            ct += 1
    l.append(ct)
    len_l = len(l)
    if len_l // 2 <= K:
        return sum(l)
    ans = res = sum(l[: 2 * K + 1])
    if len_l % 2 == 0:
        l.append(0)
        len_l += 1
    g = K * 2 + 1
    for i in range(K * 2 + 1, len_l - 1, 2):
        ans -= l[i - g] + l[i - g + 1]
        ans += l[i] + l[1 + i]
        if res < ans:
            res = ans
    # print(S)
    # print(l)
    # print(len_l)
    return res


print((Solve()))

import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


def Solve():
    N, K = na()
    S = eval(input())
    l = []
    N = len(S)
    # print(len(S))
    if S[0] == "0":
        # print("00")
        l.append(0)
    t = S[0]
    ct = 1
    # print("aa")
    # print(S)
    # print(S[0],S[1],S[2])
    for b in S[1:]:
        # print(b)
        if t != b:
            l.append(ct)
            ct = 1
            t = b
        else:
            ct += 1
    # print("bb")
    l.append(ct)
    len_l = len(l)
    if len_l // 2 <= K:
        return sum(l)
    ans = res = sum(l[: 2 * K + 1])
    if len_l % 2 == 0:
        l.append(0)
        len_l += 1
    g = K * 2 + 1
    for i in range(K * 2 + 1, len_l - 1, 2):
        ans -= l[i - g] + l[i - g + 1]
        ans += l[i] + l[1 + i]
        if res < ans:
            res = ans
    # print(S)
    # print(l)
    # print(len_l)
    return res


print((Solve()))

-    S = [int(d) for d in eval(input())] +    S = eval(input()) -    if S[0] == 0: +    # print(len(S)) +    if S[0] == "0": +        # print("00") -    b = S[0] +    t = S[0] -    for i in S[1:]: -        if b != i: +    # print("aa") +    # print(S) +    # print(S[0],S[1],S[2]) +    for b in S[1:]: +        # print(b) +        if t != b: -            b = i +            t = b +    # print("bb")