import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    s <- length . group <$> getLine
    print $ solve n s k

solve n s 0 = n - s
solve n s k
    | s <= 3 = n - s
    | otherwise = solve n (s - 2) (k - 1)