n, q = gets.split.map(&:to_i)
s = gets.chomp.split("")
gorem_pos = Array.new(n+2, 1)
gorem_pos[0] = 0
gorem_pos[n+1] = 0
index = Hash.new()

n.times do |i|
  if index[s[i]].nil?
    index[s[i]] = [i+1]
  else
    index[s[i]].append(i+1)
  end
end

q.times do
  t, d = gets.split
  if index.has_key?(t)
    index[t].each do |i|
      if d == "L"
        gorem_pos[i-1] += gorem_pos[i]
      else
        gorem_pos[i+1] += gorem_pos[i]
      end
      gorem_pos[i] = 0
    end
  end
end

sum = 0
n.times do |i|
  sum += gorem_pos[i+1]
end

puts sum