f spell s g
 |null spell = g
 |(spell!!0!!1)=='R' = f (drop 1 spell) s (zipWith (\sp gp -> if sp==(spell!!0!!0) then gp+1 else gp) s g)
 |otherwise = f (drop 1 spell) s (zipWith (\sp gp -> if sp==(spell!!0!!0) then gp-1 else gp) s g)
main=do
 [n,q]<-map read.words<$>getLine
 s<-getLine
 let g = [1..n]
 spell<-map read.words (lines<$>getContents)
 print$length$filter (>=1) (filter (<=n) (f spell s g))
 
 