require 'pp'

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

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

def bsearch_left(i, j)
  if i+1 == j
    return i
  else
    mid = (i+j)/2
    if reaches_left(mid)
      bsearch_left(mid,j)
    else
      bsearch_left(i,mid)
    end
  end
end

def bsearch_right(i, j)
  if i+1 == j
    return j
  else
    mid = (i+j)/2
    if reaches_right(mid)
      bsearch_right(i,mid)
    else
      bsearch_right(mid,j)
    end
  end
end

def reaches_left(pos)
  return false if pos >= N
  return true if pos < 0
  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
  return true if pos >= N
  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_right(3)

lidx = bsearch_left(-1, N)
ridx = bsearch_right(lidx, N)
# pp lidx,ridx
puts N - ((lidx+1) + (N-ridx))
