import sys

input = sys.stdin.readline



def main():

    n, k = [int(i) for i in input().split()]

    s = eval(input()) + "3"

    s0 = []

    s1 = []

    cnt = 0

    start = 1

    for i in range(n+1):

        if start == 1 and s[i] != "1":

            s1.append(cnt)

            cnt = 1

            start = 0

        elif start == 0 and s[i] != "0":

            s0.append(cnt)

            cnt = 1

            start = 1

        else:

            cnt += 1



    #ans = max(s1)

    #for i in range(n // 2 +1):

    #    ans = max(ans, sum(s1[i:i+k+1]) + sum(s0[i:i+k]))



    ans = sum(s1[0:0+k+1]) + sum(s0[0:0+k])

    n_ans = ans



    for i in range(n):

        try:

            n_ans = n_ans + s1[k+1+i] + s0[k+i] - s1[i] - s0[i]

            ans = max(ans, n_ans)

        except:

            try:

                n_ans = n_ans + s0[k+i] - s1[i] - s0[i]

                ans = max(ans, n_ans)

            except:

                pass



    print(ans)

    #print(s1, s0)



main()
def main():

    n, k = [int(i) for i in input().split()]

    s = eval(input()) + "3"

    s0 = []

    s1 = []

    cnt = 0

    start = 1

    for i in range(n+1):

        if start == 1 and s[i] != "1":

            s1.append(cnt)

            cnt = 1

            start = 0

        elif start == 0 and s[i] != "0":

            s0.append(cnt)

            cnt = 1

            start = 1

        else:

            cnt += 1

    if len(s0) == len(s1):

        s1.append(0)



    ans = sum(s1[0:0+k+1]) + sum(s0[0:0+k])

    n_ans = ans

    for i in range(len(s0) - k):

        n_ans = n_ans + s1[k+1+i] + s0[k+i] - s1[i] - s0[i]

        ans = max(ans, n_ans)

        

    print(ans)



main()
import sys

input = sys.stdin.readline


def main():
    n, k = [int(i) for i in input().split()]
    s = eval(input()) + "3"
    s0 = []
    s1 = []
    cnt = 0
    start = 1
    for i in range(n + 1):
        if start == 1 and s[i] != "1":
            s1.append(cnt)
            cnt = 1
            start = 0
        elif start == 0 and s[i] != "0":
            s0.append(cnt)
            cnt = 1
            start = 1
        else:
            cnt += 1
    # ans = max(s1)
    # for i in range(n // 2 +1):
    #    ans = max(ans, sum(s1[i:i+k+1]) + sum(s0[i:i+k]))
    ans = sum(s1[0 : 0 + k + 1]) + sum(s0[0 : 0 + k])
    n_ans = ans
    for i in range(n):
        try:
            n_ans = n_ans + s1[k + 1 + i] + s0[k + i] - s1[i] - s0[i]
            ans = max(ans, n_ans)
        except:
            try:
                n_ans = n_ans + s0[k + i] - s1[i] - s0[i]
                ans = max(ans, n_ans)
            except:
                pass
    print(ans)
    # print(s1, s0)


main()

def main():
    n, k = [int(i) for i in input().split()]
    s = eval(input()) + "3"
    s0 = []
    s1 = []
    cnt = 0
    start = 1
    for i in range(n + 1):
        if start == 1 and s[i] != "1":
            s1.append(cnt)
            cnt = 1
            start = 0
        elif start == 0 and s[i] != "0":
            s0.append(cnt)
            cnt = 1
            start = 1
        else:
            cnt += 1
    if len(s0) == len(s1):
        s1.append(0)
    ans = sum(s1[0 : 0 + k + 1]) + sum(s0[0 : 0 + k])
    n_ans = ans
    for i in range(len(s0) - k):
        n_ans = n_ans + s1[k + 1 + i] + s0[k + i] - s1[i] - s0[i]
        ans = max(ans, n_ans)
    print(ans)


main()

-import sys - -input = sys.stdin.readline - - -    # ans = max(s1) -    # for i in range(n // 2 +1): -    #    ans = max(ans, sum(s1[i:i+k+1]) + sum(s0[i:i+k])) +    if len(s0) == len(s1): +        s1.append(0) -    for i in range(n): -        try: -            n_ans = n_ans + s1[k + 1 + i] + s0[k + i] - s1[i] - s0[i] -            ans = max(ans, n_ans) -        except: -            try: -                n_ans = n_ans + s0[k + i] - s1[i] - s0[i] -                ans = max(ans, n_ans) -            except: -                pass +    for i in range(len(s0) - k): +        n_ans = n_ans + s1[k + 1 + i] + s0[k + i] - s1[i] - s0[i] +        ans = max(ans, n_ans) -    # print(s1, s0)