{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  [n, k] <- readInts
  s <- getLine
  print $ solve k s

solve :: Int -> String -> Int
solve k s = go 0 k (group s) + count s
  where
    go !acc 0 _ = acc
    go !acc _ [_] = acc
    go !acc _ [_,_] = 1 + acc
    go !acc !k (_:x:xs) =  go (acc + 2) (k - 1) (x:xs)

count :: String -> Int
count s = go 0 'X' s
  where
    go !acc _ [] = acc
    go !acc 'R' ('R':s) = go (acc + 1) 'R' s
    go !acc 'L' ('L':s) = go (acc + 1) 'L' s
    go !acc _ (c:s) = go acc c s