{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char

main :: IO ()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Int]
  s <- getLine
  print $ solve n k $ map digitToInt s

-- solve :: Int -> Int -> [Int] -> Int
solve n k s = maximum . calck code $ drop (2 * k) code
  where
    code = encode s
    encode :: [Int] -> [(Int, Int)]
    encode = go []
      where
        go :: [(Int, Int)] -> [Int] -> [(Int, Int)]
        go [] (s:ss) = go [(s, 1), (abs (s-1), 0)] ss
        go t [] = let (s, n) = head t in ((abs (s-1), n):t)
        go ((t, n):ts) (s:ss)
         | t == s = go ((s, n + 1):ts) ss
         | otherwise = go ((s, n + 1):(t, n):ts) ss

    calck :: [(Int, Int)] -> [(Int, Int)] -> [Int]
    calck _ [] = [0]
    calck (c:cs) (b:bs)
      | s == 1 = if null bs 
                 then [nc - nb]
                 else (nc - nbb):(calck cs bs)
      | s == 0 = (nc - nb):(calck cs bs)
      where
        (s, nc) = c
        (_, nb) = b
        (_, nbb) = head bs

