import Data.List
import Data.Array

--for 1 prior

--change 0 to 1
preproc::String->[Int]
preproc str = let grpd =  (group str) in case (head str, last str) of
                                        ('1','1') ->map length grpd
                                        ('0','1') ->0:(map length grpd)
                                        ('1','0') ->(map length grpd)++[0]
                                        ('0','0') ->0:(map length grpd)++[0]



foldl_trace::(b->a->b)->b->[a]->[b]
foldl_trace _ _ []     = []
foldl_trace f y (x:xs) = (f y x):foldl_trace f (f y x) xs

sum_nth::[Int]->Array Int Int
sum_nth ls = listArray (0,length ls) (0:(foldl_trace (+) 0 ls))

sum_nth_1::Array Int Int->Int->Int
sum_nth_1  ar n = ar!(2*n)

sum_nth_1_and_0::Array Int Int->Int->Int
sum_nth_1_and_0 ar n = ar!((2*n)+1)

solver::String->Int->Int
solver str k = let num_1 = length (filter (\l-> head l == '0') (group str)) in
               if  num_1 <= k
                then length str
                else let ar = sum_nth (preproc str) in
                     let (s,e) = bounds ar in
                     let idx = takeWhile (\ (_,r) -> (2*r+1) <= e ) [(i,i+k)|i<-[0..]] in
                     maximum [(sum_nth_1_and_0 ar r)-(sum_nth_1 ar l) |(l,r)<-idx]

main::IO()
main=do
  (_:k:[])<-return.map read.words=<<getLine
  str<-getLine
  print (solver str k) 
