import Data.List
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  s <- map (\s -> (head s, length s)) . group <$> getLine
  print . maximum . map (sum . map snd .tn k) $ ts s

tn n s@(('0',_):_) = take (2*n) s
tn n s@(('1',_):_) = take (2*n+1) s

dn n s@(('0',_):_) = drop (2*n-1) s
dn n s@(('1',_):_) = drop (2*n) s

ts [] = []
ts s = s : (ts $ dn 1 s) 