import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= main'
    where
        main' [n, k] = getLine >>= print . solve k

solve :: Int -> String -> Int
solve k ss = check acc0 acc0 ns xs0
    where
        ns = map ((,) <$> head <*> length) . group $ map (== '1') ss
        (acc0, xs0) = count k 0 ns

        check acc pcc pps@((pb, pl) : ps) xxs@(_ : _)
            | pb = check (max acc rcc) rcc ps ys
            | otherwise = check (max acc rcc2) rcc2 ps ys2
            where
                rcc = pcc - pl + bls
                (bls, ys) = count 0 0 xxs

                rcc2 = pcc - pl + bls2
                (bls2, ys2) = count 1 0 xxs
        check acc _ _ _ = acc

        count n acc xxs@((b, l) : xs)
            | b = count n (acc + l) xs
            | n > 0 = count (n - 1) (acc + l) xs
            | otherwise = (acc, xxs)
        count _ acc _ = (acc, [])

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine
