n, q = gets.split.map(&:to_i)
s = gets.chomp.chars
spells = Array.new(q) { gets.chomp.split }

s = ["@"] + s + ["@"]

# i番目（先頭は1）のゴーレムの最終位置
query = ->i {
  spells.each do |t, d|
    if t == s[i]
      d == "L" ? i -= 1 : i += 1
    end
  end
  i
}

hi = (0..n + 1).bsearch { |i| query[i] == n + 1 } # 右に落ちる
lo = n + 1 - (0..n + 1).bsearch { |i| query[n + 1 - i] == 0 } # 左に落ちる

ans = hi - 1 - lo
puts ans