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

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  ds <- map (== 'R') <$> getLine :: IO [Bool]
  let
    d1 = head ds
    (h, x, o, Just dn) = foldl step (0, 0, 0, Nothing) $ ds :: (Int, Int, Int, Maybe Bool)
    step (h, x, o, Just d') d | d' && not d = (h, succ x, o, Just d)
                              | not d' && d = (h, x, succ o, Just d)
                              | otherwise = (succ h, x, o, Just d)
    step _ d = (0, 0, 0, Just d)
    m = min x o
  print $ h + f k m (x - m) (o - m) d1 dn

f :: Int -> Int -> Int -> Int -> Bool -> Bool -> Int
f k m x o d1 dn
  | k <= m = 2 * k
  | otherwise
    =
      let
          k' = k - m
          (a, o') = if not d1 && 1 <= o then (1, pred o) else (0, o)
          b = if dn && 1 <= o' then 1 else 0
        in
          2 * m + min k' (a + b)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
