-- ABC124 D problem
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.Text as T
import qualified Data.Vector as V

-- conversion from String to Int
toInt :: String -> Int
toInt x = read x :: Int
 
-- obtain [Int] from I/O
getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map $ toInt) $ words x
  return y

-- cumulative sum with list
cumsum :: [Int] -> Int -> [Int]
cumsum [] n = []
cumsum (x:xs) n = [x+n] ++ (cumsum xs (x+n))

-- cumulative sum with V.vector
cumsumV :: V.Vector Int -> V.Vector Int
cumsumV vec =
  V.generate (1 + (V.length vec)) p_sum where p_sum = \n -> V.sum $ V.slice 0 n vec

abc124d :: V.Vector Char -> V.Vector Int -> Int -> Int -> V.Vector Int -> V.Vector Int
abc124d s1 leng n k btoe=
  let shift = \i -> if (s1 V.! (leng V.! i)) == '0' then 2*k else 2*k+1 :: Int
      gain = \i ->
        if i+(shift i) >= (V.length leng) then n - (leng V.! i) else (leng V.! (i+(shift i))) - (leng V.! i)
  in V.map gain btoe

-- main function
main :: IO ()
main = do
  [n, k] <- getInts
  s <- getLine
  let s1 = V.fromList s
  let v = map length (group s)
  let leng = V.fromList (0 : (cumsum v 0))
  let btoe = V.fromList [0..(V.length leng - 2)]
  print $ V.maximum $ abc124d s1 leng n k btoe