
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad

import qualified Data.IntMap as M
import qualified Data.Sequence as S

import Data.Foldable(toList)
import Data.Maybe(fromMaybe)


r :: IO [Int]
r  = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    where toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,k] <- r :: IO [Int]
    s <- getLine 
    let mA = maxAdd s
    let add = min k mA
    let rest = k - mA
    let spA = if rest > 0 && length (nub s) > 0 then 1 else 0 
    --print spA
    print $ hap s + (add * 2) + spA

happ :: Char -> Char -> Char -> Int
happ 'L' 'L'  _  = 1
happ  _  'R' 'R' = 1
happ  _   _   _  = 0

hap :: String -> Int
hap ls = let ls' = 'X':ls++"X"
            in  sum $ zipWith3 happ ls' (tail ls') (tail $ tail ls')

maxAdd :: String -> Int
maxAdd ls = let (x,y) = grenz (0,0) ls 
    in div x 2 + (div y 2)

grenz :: (Int,Int) -> String -> (Int,Int) 
grenz (lr,rl) ('L':'R':xs) = grenz (lr+1,rl) ('R':xs)
grenz (lr,rl) ('R':'L':xs) = grenz (lr,rl+1) ('L':xs)
grenz (lr,rl) ( _ : x :xs) = grenz (lr,rl) (x:xs)
grenz ac _ = ac 


