import Data.List (group)

count0 :: String -> Int
count0 []     = 0
count0 xs =
  let ys = map (\xs@(x:_) -> (x, length xs)) $ group xs
      zs = filter (\(x, _) -> x == '0') ys
   in if length zs == 0 then 0 else maximum (map snd zs)

count1 :: String -> Int
count1 []     = 0
count1 xs =
  let ys = map (\xs@(x:_) -> (x, length xs)) $ group xs
      zs = filter (\(x, _) -> x == '1') ys
   in if length zs == 0 then 0 else maximum (map snd zs)

directions :: Int -> Int -> String -> String
directions l r xs = map (\(x, i) -> if l <= i && i <= r then f x else x) $ zip xs [0..]
  where
    f '0' = '1'
    f '1' = '0'

maxDirections :: String -> [String]
maxDirections [] = []
maxDirections xs = do
 let n = length xs
     ys = do
          l <- [0..n-1]
          r <- [l..n-1]
          pure $ directions l r xs
     max0 = maximum $ map count0 ys
     max1 = maximum $ map count1 ys

  in (if (max0 < count0 xs || max1 < count1 xs) then (xs:) else id) $ filter (\xs -> count0 xs == max0 || count1 xs == max1) ys
 


main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  xs     <- getLine
  let aaa 0 xs = xs
      aaa k xs = aaa (k-1) (concatMap maxDirections xs)
      cands = aaa k [xs]
      ys = do
           l <- [0..n-1]
           r <- [l..n-1]
           pure $ directions l r xs
  print $ maximum $ map count1 cands

