N,Q = readline.chomp.split.map(&:to_i)
S = readline.chomp

OPS = []
Q.times do
  c,dir = readline.chomp.split
  d = (dir == 'L') ? -1 : 1
  OPS << [c,d]
end

def dest(pos)
  OPS.each do |c,d|
    if S[pos] == c
      pos += d
      break if pos < 0 or pos >= N
    end
  end
  pos
end


lidx = (0..(N-1)).bsearch {|i| dest(i) >= 0 } || N
ridx = (lidx..(N-1)).bsearch {|i| dest(i) >= N } || N
puts ridx - lidx
