import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    f :: Int -> Int -> Int
    f k m = (2 * k) `min` (m - 1)
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    step :: Char -> [Bool] -> [Bool]
    step 'L' rest = False : rest
    step 'R' rest = True : rest
    step _ _ = []
  ds <- foldr step [] <$> getContents :: IO [Bool]
  let
    (m, s) = fst . foldl step ((0, 0), Nothing) $ ds :: (Int, Int)
      where
        step :: ((Int, Int), Maybe Bool) -> Bool -> ((Int, Int), Maybe Bool)
        step ((m, s), Just x) y | x == y    = ((m, s + 1), Just x)
        step ((m, s), _) y                  = ((m + 1, s), Just y)
  print $ s + f k m

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
