n,k=list(map(int,input().split()))

s=eval(input())



if s[0]=='0':

    seq=[0]

else:

    seq=[]



i=0

while i<n:

    j=i

    while j<n and s[j]==s[i]:

        j+=1

    seq.append(j-i)

    i=j



if s[-1]=='0':

    seq.append(0)



bleft=0

bright=min(2*k,len(seq)-1)



cursum=sum(seq[bleft:bright+1])

ret=cursum



for i in range(2,len(seq),2):

    left=i

    right=min(i+2*k,len(seq)-1)



    if bleft!=left:

        cursum-=seq[bleft]+seq[bleft+1]

        bleft=left

    if bright!=right:

        cursum+=seq[right-1]+seq[right]

        bright=right

    

    ret=max(ret,cursum)

    

print(ret)

from itertools import accumulate



n,k=list(map(int,input().split()))

s=eval(input())



i=0

if s[0]=='1':

    lst=[]

else:

    lst=[0]



while i<n:

    j=i

    cnt=0

    while j<n and s[i]==s[j]:

        cnt+=1

        j+=1

    

    lst.append(cnt)

    i=j



if 2*k+1>=len(lst):

    print(n)

    exit(0)



csum=list(accumulate(lst))

cur=csum[2*k]

ans=cur

for i in range(2,len(lst),2):

    right=min(i+2*k,len(lst)-1)



    ans=max(ans,csum[right]-csum[i-1])



print(ans)

n, k = list(map(int, input().split()))
s = eval(input())
if s[0] == "0":
    seq = [0]
else:
    seq = []
i = 0
while i < n:
    j = i
    while j < n and s[j] == s[i]:
        j += 1
    seq.append(j - i)
    i = j
if s[-1] == "0":
    seq.append(0)
bleft = 0
bright = min(2 * k, len(seq) - 1)
cursum = sum(seq[bleft : bright + 1])
ret = cursum
for i in range(2, len(seq), 2):
    left = i
    right = min(i + 2 * k, len(seq) - 1)
    if bleft != left:
        cursum -= seq[bleft] + seq[bleft + 1]
        bleft = left
    if bright != right:
        cursum += seq[right - 1] + seq[right]
        bright = right
    ret = max(ret, cursum)
print(ret)

from itertools import accumulate

n, k = list(map(int, input().split()))
s = eval(input())
i = 0
if s[0] == "1":
    lst = []
else:
    lst = [0]
while i < n:
    j = i
    cnt = 0
    while j < n and s[i] == s[j]:
        cnt += 1
        j += 1
    lst.append(cnt)
    i = j
if 2 * k + 1 >= len(lst):
    print(n)
    exit(0)
csum = list(accumulate(lst))
cur = csum[2 * k]
ans = cur
for i in range(2, len(lst), 2):
    right = min(i + 2 * k, len(lst) - 1)
    ans = max(ans, csum[right] - csum[i - 1])
print(ans)

+from itertools import accumulate + -if s[0] == "0": -    seq = [0] +i = 0 +if s[0] == "1": +    lst = [] -    seq = [] -i = 0 +    lst = [0] -    while j < n and s[j] == s[i]: +    cnt = 0 +    while j < n and s[i] == s[j]: +        cnt += 1 -    seq.append(j - i) +    lst.append(cnt) -if s[-1] == "0": -    seq.append(0) -bleft = 0 -bright = min(2 * k, len(seq) - 1) -cursum = sum(seq[bleft : bright + 1]) -ret = cursum -for i in range(2, len(seq), 2): -    left = i -    right = min(i + 2 * k, len(seq) - 1) -    if bleft != left: -        cursum -= seq[bleft] + seq[bleft + 1] -        bleft = left -    if bright != right: -        cursum += seq[right - 1] + seq[right] -        bright = right -    ret = max(ret, cursum) -print(ret) +if 2 * k + 1 >= len(lst): +    print(n) +    exit(0) +csum = list(accumulate(lst)) +cur = csum[2 * k] +ans = cur +for i in range(2, len(lst), 2): +    right = min(i + 2 * k, len(lst) - 1) +    ans = max(ans, csum[right] - csum[i - 1]) +print(ans)