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