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

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