N, Q = gets.split.map(&:to_i)
S = gets.chomp
QUERIES = Q.times.map { gets.chomp.split }

def f(x, pos)
  cur = x

  return true if x == pos

  QUERIES.each do |t, d|
    next if S[cur] != t

    if d == 'L'
      cur -= 1
    else
      cur += 1
    end

    return true if cur == pos
  end

  false
end

ok = -1
ng = N - 1

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid, -1)
    ok = mid
  else
    ng = mid
  end
end

right = ng

ok = N
ng = 1

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid, N)
    ok = mid
  else
    ng = mid
  end
end

left = ng

puts (right - left).abs + 1
