import Data.List
main = do
  [n,k] <- map read . words <$> getLine :: IO[Int]
  s <- getLine
  let gs = group s
  let g0 = map length (filter (\x -> head x == '0') gs)
  let g1 = map length (filter (\x -> head x == '1') gs)
  let g12 = zipWith (+) g0 g1
  let ians = if k >= length g0 then sum g12 else (if head s == '0' then sum (take k g12) else sum (take k g12) + g1 !! k)
  print $ if head s == '0' then maximum (f g12 g0 [ians] k) else maximum (g g12 g1 [ians] k)

f x12 x0 ans y
  | y > length x12 = ans
  | y <= length x12 = f (tail x12) (tail x0) (ans ++ [last ans - head x0 + x12 !! y]) y
g x12 x1 ans y
  | y > length x12 = ans
  | y == length x12 = ans ++ [sum x12]
  | y-1 == length x12 = g (tail x12) (tail x1) (ans ++ [last ans - head x12 + x12 !! y + last x1 ]) y
  | y-1 < length x12 = g (tail x12) (tail x1) (ans ++ [last ans - head x12 + x12 !! y + x1 !! (y+1)]) y