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
    elif typ is char:   line.mapIt(it[0])
  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)
    elif typ is char:   line.mapIt(it[0]).unpack(cnt)

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

var (N, Q) = input(int, 2)
var S = input(string, 1); S = "#" & S & "#"
var T, D = newseq[char](N + 1)
for i in 1..Q:
  (T[i], D[i]) = input(char, 2)

proc judge(x: int, dir: int): bool =
  var x = x
  for i in 1..Q:
    if S[x] == T[i]:
      if D[i] == 'L':
        x -= 1
      else:
        x += 1
  if (x == 0 and dir == 1) or (x == N + 1 and dir == 2):
    return true
  else:
    return false

proc myBinarySearch(dir: int): int =
  var ok: int # 落ちる
  var ng: int # 落ちない
  if dir == 1:
    (ok, ng) = (0, N + 1)
  else:
    (ok, ng) = (N + 1, 0)
  while abs(ok - ng) > 1:
    var mid = (ok + ng) div 2
    if judge(mid, dir) == true:
      ok = mid
    else:
      ng = mid
  return ng

var res = myBinarySearch(2) - myBinarySearch(1) + 1
echo res