import           Control.Exception  (assert)
import           Control.Monad      (replicateM)
import           Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IM (delete, fromDistinctAscList,
                                           mapKeysMonotonic, partitionWithKey,
                                           unionWith)
import           Data.List          (foldl')
import           Data.Map.Strict    (Map)
import qualified Data.Map.Strict    as M (findWithDefault, fromListWith)

main :: IO ()
main = do
  [n, q] <- map read . words <$> getLine
  s <- getLine
  assert (length s == n) $ do
    spells <- replicateM q $ do
      [t, d] <- words <$> getLine
      pure $ toSpell t d
    print $ solve n s spells

data Spell = L Char | R Char deriving Show

toSpell :: String -> String -> Spell
toSpell [c] "L" = L c
toSpell [c] "R" = R c
toSpell _   _   = error "irregular"

type Index = Map Char [Int]
type Field = IntMap Int

solve :: Int -> String -> [Spell] -> Int
solve n s spells = sum $ foldl' (flip (update' n (index s))) (initial n) spells

index :: String -> Map Char [Int]
index s = M.fromListWith (++) $ zip s $ map pure [1..]

initial :: Int -> Field
initial n = IM.fromDistinctAscList $ zip [1..n] $ repeat 1

update' :: Int -> Index -> Spell -> Field -> Field
update' n index' (L c) field =
  let
    targetIndeces = M.findWithDefault [] c index'
    (target, rest) = IM.partitionWithKey (\k _ -> k `elem` targetIndeces) field
  in
    IM.unionWith (+) (cut n $ IM.mapKeysMonotonic pred target) rest
update' n index' (R c) field =
  let
    targetIndeces = M.findWithDefault [] c index'
    (target, rest) = IM.partitionWithKey (\k _ -> k `elem` targetIndeces) field
  in
    IM.unionWith (+) (cut n $ IM.mapKeysMonotonic succ target) rest

cut :: Int -> Field -> Field
cut n = IM.delete 0 . IM.delete (n + 1)
