import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as BS

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

f :: String -> Int
f (b:b':bs) = if b == b' then f (b':bs) else 1+(f $ b':bs)
f _ = 0

main :: IO ()
main = do
  [n,k] <- getIntList
  s <- getLine
  let b = f s
  print $ (n-1)-b+(min b $ 2*k)
