import algorithm, hashes, macros, math, sequtils, sets, strutils, tables, times, unicode

macro unpack*(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  if NimMinor <= 17:
    for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])
  else:
    for i in 0..<cnt: result[1].add(quote do:`t`[`i`])

template input*(typ: typedesc, cnt: Natural = 0): untyped =
  let line = stdin.readLine.split(" ")
  when cnt == 0:
    when typ is int:    line.map(parseInt)
    elif typ is float:  line.map(parseFloat)
    elif typ is string: & line
  else:
    when typ is int:    line.map(parseInt).unpack(cnt)
    elif typ is float:  line.map(parseFloat).unpack(cnt)
    elif typ is string: line.unpack(cnt)

# -------------------------------------------------- #

var (N, Q) = input(int, 2)
var S = input(string, 1); S = "#" & S

var otiru = newseq[bool](N + 1)
var left = 0
var right = N + 1

var T = newseq[string](Q + 1)
var D = newseq[string](Q + 1)
for i in 1..Q:
  (T[i], D[i]) = input(string, 2)

for i in countdown(Q, 1):
  var (t, d) = (T[i], D[i])
  if d == "L":
    var target = S[(left + 1)..(left + 1)]
    if target == t:
      left += 1
      otiru[left] = true
    # ?
    if S[right..right] == t:
      otiru[right] = false
      right += 1
  if d == "R":
    var target = S[(right - 1)..(right - 1)]
    if target == t:
      right -= 1
      otiru[right] = true
    # ?
    if S[left..left] == t:
      otiru[left] = false
      left -= 1

var cnt = 0
for i in 1..N:
  if otiru[i]:
    cnt += 1

var res = N - cnt
echo res