import Control.Applicative import Data.Char (digitToInt) main :: IO () main = solve <$> f <*> getLine >>= print where f = map read <$> words <$> getLine solve :: [Int] -> String -> Int solve [_, k] s = f 0 0 0 . cycle $ map digitToInt s where f bc ic at xs | ic >= k = bc | at > 0 = let ls = take at xs in f bc (ic+at) (sum ls) (drop at xs) | otherwise = f (bc+1) (ic+1) (head xs) (tail xs)