N,K=gets.split.map(&:to_i)
as=gets.chomp.codepoints
zero,one="01".codepoints
con=as[0]==zero ? true : false
as.unshift(one) if con
ts=Array.new
flag=one
i=-1
cnt=0
while i<=N-1
  i+=1
  if flag==as[i] && i!=N
    cnt+=1
  else
    ts << cnt
    flag=flag==one ? zero : one
    cnt=1
  end
end
ts_sum=Array.new(ts.size)
ts_sum[0]=ts[0]
for i in 1..ts.size-1
  ts_sum[i]=ts_sum[i-1]+ts[i]
end

ans=Array.new

ts.each_cons([2*K+1,ts.size].min).with_index do |es,i|
  if i.even?
    ans << (i==0 && con ? es.inject(:+)-1 : es.inject(:+))
  end
end
puts ans.max
