n, q = gets.chomp.split(' ').map{|x| x.to_i}
s = gets.chomp
a = readlines.map{|x| x.chomp.split(' ')}

h = {}
s.split('').each_with_index do |c, i|
(  h[c] ||= []) << i
end

ma = Array.new(n, 1)
a.each do |t, d|
  next unless h.has_key?(t)
  if d == 'L'
    h[t].each do |i|
      ma[i-1] += ma[i] if i > 0
      ma[i] = 0
    end
  else 
    h[t].each do |i|
      ma[i+1] += ma[i] if i < n-1
      ma[i] = 0
    end
  end
end

puts ma.inject(0){|s, x| s += x}
