-- ABC124 D problem
import Control.Monad
import qualified Data.Text as T

-- conversion from String to Int
toInt :: String -> Int
toInt x = read x :: Int

-- obtain [Int] from I/O
getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map $ toInt) $ words x
  return y

subf :: Char -> Int
subf '0' = 0
subf '1' = 1

swpoints :: T.Text -> [[Int]]
swpoints s =
  if (T.tail s) == T.empty then [[0], [subf (T.head s)]]
  else
    if (T.head s) /= (T.head (T.tail s)) then 
      [(head (swpoints (T.tail s))) ++ [T.length (T.tail s)], (last (swpoints (T.tail s))) ++ [subf (T.head s)]]
    else (swpoints (T.tail s))

shift :: [Int] -> Int -> Int -> [Int]
shift x n 0 = x
shift (x:xs) n sh = shift (xs ++ [n]) n (sh-1)

gains :: [Int] -> [Int] -> [Int] -> [Int] -> [Int]
gains [] [] [] [] = []
gains (p:ps) (p1:p1s) (p2:p2s) (q:qs) =
  case q of
    0 -> [p1-p] ++ (gains ps p1s p2s qs)
    1 -> [p2-p] ++ (gains ps p1s p2s qs)

maxi :: [Int] -> Int
maxi [] = 0
maxi (x:xs) = max x (maxi xs)

-- main function
main :: IO ()
main = do
  nk <- getInts
  let n = head nk
  let k = last nk
  s <- getLine
  let is = swpoints (T.pack s)
  let p = head is
  let q = last is
  let p1 = shift p n (2*k)
  let p2 = shift p n (2*k+1)
  print (maxi (gains p p1 p2 q))