debug = false
n, _ = gets.chomp.split.map(&:to_i)
s = gets.chomp.split(//)
 
# setup map
if debug
  map = {}
  map.default = []
 
  n.times do |j|
    p [s[j], j]
    map[s[j]].push j
  end
 
  puts map
end
 
#
lc=0
count = Array.new(n, 1)
 
hash = {}
n.times do |j|
  hash[s[j]] = true
end
 
lines = $stdin.readlines
lines.each do |line|
  t = line[0]
  d = line[2]
 
  next if hash[t].nil?
  hash = {}
 
  n.times do |j|
    if s[j] == t
      if d == 'L'
        if j > 0
          count[j-1] += count[j]
          hash[s[j-1]] = true
        end
      else # R
        if j < n-1
          count[j+1] += count[j]
          hash[s[j+1]] = true
        end
      end
      count[j] = 0
    else
      hash[s[j]] = true
    end
    lc += 1 if debug
  end
end
 
# p count
puts count.inject(:+)
puts lc if debug