import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

import random



sys.setrecursionlimit(10**7)

inf = 10**20

eps = 1.0 / 10**10

mod = 10**9+7

dd = [(-1,0),(0,1),(1,0),(0,-1)]

ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]



def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]

def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]

def LF(): return [float(x) for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

def I(): return int(sys.stdin.readline())

def F(): return float(sys.stdin.readline())

def S(): return input()

def pf(s): return print(s, flush=True)



def main():

    n,k = LI()

    s = [int(c) for c in S()]

    a = []

    if s[0] == 0:

        a.append(0)

    t = s[0]

    c = 1

    for b in s[1:]:

        if t == b:

            c += 1

        else:

            a.append(c)

            c = 1

            t = b

    a.append(c)

    l = len(a)

    if l // 2 <= k:

        return sum(a)



    r = t = sum(a[:k*2+1])

    if l % 2 == 0:

        a.append(0)

        l += 1

    g = k * 2 + 1

    for i in range(k*2+1,l-1,2):

        t -= a[i-g] + a[i-g+1]

        t += a[i] + a[i+1]

        if r < t:

            r = t



    return r





print(main())



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 math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LLI():
    return [tuple(map(int, l.split())) for l in sys.stdin]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def LF():
    return [float(x) for x in sys.stdin.readline().split()]


def LS():
    return sys.stdin.readline().split()


def I():
    return int(sys.stdin.readline())


def F():
    return float(sys.stdin.readline())


def S():
    return input()


def pf(s):
    return print(s, flush=True)


def main():
    n, k = LI()
    s = [int(c) for c in S()]
    a = []
    if s[0] == 0:
        a.append(0)
    t = s[0]
    c = 1
    for b in s[1:]:
        if t == b:
            c += 1
        else:
            a.append(c)
            c = 1
            t = b
    a.append(c)
    l = len(a)
    if l // 2 <= k:
        return sum(a)
    r = t = sum(a[: k * 2 + 1])
    if l % 2 == 0:
        a.append(0)
        l += 1
    g = k * 2 + 1
    for i in range(k * 2 + 1, l - 1, 2):
        t -= a[i - g] + a[i - g + 1]
        t += a[i] + a[i + 1]
        if r < t:
            r = t
    return r


print(main())

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 math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools -import random +import sys -sys.setrecursionlimit(10**7) -inf = 10**20 -eps = 1.0 / 10**10 -mod = 10**9 + 7 -dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] -ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] +stdin = sys.stdin +ni = lambda: int(ns()) +na = lambda: list(map(int, stdin.readline().split())) +ns = lambda: stdin.readline() -def LI(): -    return list(map(int, sys.stdin.readline().split())) +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 -def LLI(): -    return [tuple(map(int, l.split())) for l in sys.stdin] - - -def LI_(): -    return [int(x) - 1 for x in sys.stdin.readline().split()] - - -def LF(): -    return [float(x) for x in sys.stdin.readline().split()] - - -def LS(): -    return sys.stdin.readline().split() - - -def I(): -    return int(sys.stdin.readline()) - - -def F(): -    return float(sys.stdin.readline()) - - -def S(): -    return input() - - -def pf(s): -    return print(s, flush=True) - - -def main(): -    n, k = LI() -    s = [int(c) for c in S()] -    a = [] -    if s[0] == 0: -        a.append(0) -    t = s[0] -    c = 1 -    for b in s[1:]: -        if t == b: -            c += 1 -        else: -            a.append(c) -            c = 1 -            t = b -    a.append(c) -    l = len(a) -    if l // 2 <= k: -        return sum(a) -    r = t = sum(a[: k * 2 + 1]) -    if l % 2 == 0: -        a.append(0) -        l += 1 -    g = k * 2 + 1 -    for i in range(k * 2 + 1, l - 1, 2): -        t -= a[i - g] + a[i - g + 1] -        t += a[i] + a[i + 1] -        if r < t: -            r = t -    return r - - -print(main()) +print((Solve()))