import System.IO (hSetBuffering, stdin, BufferMode (NoBuffering))

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  hSetBuffering stdin NoBuffering
  ds <- getContents :: IO String
  let
    s = length . filter id . (zipWith (==) <$> id <*> tail) $ ds :: Int
  print $ (s + 2 * k) `min` (n - 1)
