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

def move(from)
  Q.inject(from) do |x, (label, dir)|
    S[x] == label ? (dir == 'L' ? (x - 1) : (x + 1)) : x
  end
end

# from       | to     | desc of status
# [0, L)     | 0      | fall to left
# [L, R)     | (0, N] | live
# [R, N + 1] | N + 1  | fall to right

L = (0 .. N + 1).bsearch{|from| move(from) > 0 }
R = (0 .. N + 1).bsearch{|from| move(from) > N }

puts R - L
