require 'pp'

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

OPS = Q.times.each.map {
  c,dir = readline.chomp.split
  d = (dir == 'L') ? -1 : 1
  [c,d]
}

def reaches_left(pos)
  OPS.each do |(c,dir)|
    if S[pos] == c
      pos += dir
      return true if pos < 0
      return false if pos >= N
    end
  end
  false
end

def reaches_right(pos)
  OPS.each do |(c,dir)|
    if S[pos] == c
      pos += dir
      return false if pos < 0
      return true if pos >= N
    end
  end
  false
end

# pp (0..(N-1)).map {|i| !reaches_left(i) }
# pp (0..(N-1)).map {|i| reaches_right(i) }
lidx = (0..(N-1)).bsearch {|i| !reaches_left(i) } || N
ridx = (0..(N-1)).bsearch {|i| reaches_right(i) } || N
# pp lidx,ridx
puts ridx - lidx
