def check(x,s,move,out)
  pos = x
  move.each do |a|
    t,d = a
    if t == s[pos]
      pos += d
    end
    break if pos == out
  end
  return pos
end 

N,Q = gets.split.map(&:to_i)
s = gets.chomp
move = []
Q.times do 
  t,d = gets.split
  move << [t,d=="L" ? -1 : 1]
end

l = ((0..N-1).bsearch{|x| check(x,s,move,-1) >= 0 } || N)
r = ((0..N-1).bsearch{|x| check(x,s,move,N) >= N } || N)
#p [l,r]
p r <= l ? 0 : r-l
