import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as M


-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'
--
-- slst <- replicateM h getLine

getBysplit = map read . words <$> getLine

countBySame' :: (Ord a) => [a] -> [Int]
countBySame' [] = []
countBySame' lst = let x:xs = lst
                       (n, list) = samelist x xs 0
                   in n : countBySame' list
  where
    samelist ::(Ord a) => a -> [a] ->  Int -> (Int, [a])
    samelist a [] n = (n+1, [])
    samelist a (x:xs) n
                  | a == x = samelist a xs (n+1)
                  | a /= x = (n+1, x:xs)

--累積和を表すListを作成する関数
cumSum :: [Int] -> [Int]
cumSum lst = 0 : makeSums 0 lst
    where
      makeSums :: Int -> [Int] -> [Int]
      makeSums acc [] = []
      makeSums acc (x:xs) = (acc+x) : makeSums (acc+x) xs

reshape :: String -> [Int] -> [Int]
reshape _ [] = undefined
reshape xs ys = case (h, t) of
                  ('1', '1') -> ys
                  ('1', '0') -> ys ++ [0]
                  ('0', '1') -> 0 : ys
                  _ -> [0] ++ ys ++ [0]
    where
      h = head xs
      t = head xs

kadd :: Int -> Int
kadd k = 2 * k + 1

solve :: Int -> Int -> M.Map Int Int -> Int
solve k limit mmap = f [0,2..limit] mmap
      where
        f :: [Int] -> M.Map Int Int -> Int
        f lst mmap = foldl g 0 lst
          where
            add :: Int
            add = kadd k

            g :: Int -> Int -> Int
            g acc left = let
              Just value1 = M.lookup left mmap
              Just value2 = M.lookup (min (left + add) limit) mmap
              in max (value2 - value1) acc

main :: IO()
main = do
  [n, k] <- getBysplit :: IO [Int]
  s <- getLine
  let nums = reshape s $ countBySame' s
  let sums = cumSum nums
  let sumsMap = M.fromList $ zip [0..] sums
  print $ solve k (length nums) sumsMap
