require 'pp'

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

OPS = Q.times.each.map { readline.chomp.split }

def bsearch(i, j, &block)
  if i+1 == j
    return i
  else
    mid = (i+j)/2
    if yield mid
      bsearch(mid,j,&block)
    else
      bsearch(i,mid,&block)
    end
  end
end

def reaches_left(pos)
  return false if pos >= N
  OPS.each do |(c,dir)|
    if S[pos] == c
      pos = (dir == 'L') ? pos-1 : pos + 1
      return true if pos < 0
    end
  end
  false
end
def reaches_right(pos)
  return false if pos < 0
  OPS.each do |(c,dir)|
    if S[pos] == c
      pos = (dir == 'L') ? pos-1 : pos + 1
      return true if pos >= N
    end
  end
  false
end
  
# pp reaches_left(2)

lidx = bsearch(0, N, & Proc.new {|x| reaches_left(x) })
ridx = bsearch(lidx, N, & Proc.new {|x| !reaches_right(x) })
puts N - ((lidx+1) + (N-1-ridx))
