import Data.List (group)
import Data.Bool (bool)
import qualified Data.Sequence as Q

main :: IO ()
main = do
  (n : k : _) <- map read . words <$> getLine :: IO [Int]
  s <- map (== '1') <$> getLine :: IO [Bool]
  let
    s' = bool id (0 :) (head s == False) . map length . group $ s
    (pr, sf) = splitAt (2 * k + 1) s'
    go (m, q) (l0 : l1 : ls) = let {(l1' Q.:< q') = Q.viewl q; (l0' Q.:< q'') = Q.viewl q'; m' = m - l1' - l0' + l0 + l1} in go (max m m', q'' Q.|> l0 Q.|> l1) ls
    go (m, q) (l0 : _) = let {(l1' Q.:< q') = Q.viewl q; (l0' Q.:< _) = Q.viewl q'; m' = m - l1' - l0' + l0} in max m m'
    go (m, _) _ = m
  print . go (sum pr, Q.fromList pr) $ sf
