N, q = gets.split.map(&:to_i)
S = "<#{gets.chomp}>"
Q = q.times.map{gets.chomp}
l,r = [1, N]

def move(pos, op)
  label = op[0]
  dir = op[2]
  S[pos] != label ? pos : (dir == 'L' ? pos - 1 : pos + 1)
end

Q.reverse_each do |op|
  l = (l - 1 .. l + 1).select{|pos| move(pos, op) >= l }.min
  r = (r - 1 .. r + 1).select{|pos| move(pos, op) <= r }.max
end

puts r < l ? N : r - l + 1