import           Control.Exception (assert)
import           Data.List         (group, tails)

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  -- people <- map fromChar <$> getLine
  people <- getLine
  assert (length people == n) $
    print $ solve k people

-- data Person =
--   Upright | Handstand
--   deriving (Eq)
type Person = Char

-- fromChar :: Char -> Person
-- fromChar '0' = Upright
-- fromChar '1' = Handstand
-- fromChar _   = undefined

-- data People = Uprights Int | Handstands Int
type People = (Char, Int)

toPeople :: [Person] -> [People]
-- toPeople = map (\ps -> f (head ps) (length ps)) . group
--   where
--     f Upright n   = Uprights n
--     f Handstand n = Handstands n
toPeople = map (\ps -> (head ps, length ps)) . group

-- sumPeople :: [People] -> Int
-- sumPeople = sum . map (\case Uprights n -> n ; Handstands n -> n)

solve :: Int -> [Person] -> Int
-- solve k = maximum . map (sumPeople . takePeaple k) . tails . toPeople
solve k = maximum . map (sum . map snd . takePeaple k) . tails . toPeople

-- 直立が k個になる +1 とる
takePeaple :: Int -> [People] -> [People]
-- takePeaple _ []                      = []
-- takePeaple 0 (p : _)                 = [p]
-- takePeaple k (p@(Uprights _)   : ps) = p : takePeaple (k - 1) ps
-- takePeaple k (p@(Handstands _) : ps) = p : takePeaple k ps
takePeaple _ []                  = []
takePeaple 0 (p : _)             = [p]
takePeaple k (p@('0', _)   : ps) = p : takePeaple (k - 1) ps
takePeaple k (p@('1', _) : ps)   = p : takePeaple k ps
takePeaple _ _                   = undefined
