n, q = map(int, input().split())
s = "#" + input() + "#"
TD = [list(input().split()) for _ in range(q)]
TD = [(t, -1) if d == "L" else (t, 1) for t, d in TD]

def test(i, end):
  color = s[i]
  for t, d in TD:
    if t == color:
      i += d
      if i == end:
        return True
      color = s[i]
  else:
    return False
  
# 左に落ちるゴーレムの数(left)を探す
ng = n + 1
ok = 0
while abs(ok - ng) > 1:
  m = (ok + ng) // 2
  if test(m, 0):
    ok = m
  else:
    ng = m
left = ok

# 右に落ちるゴーレムの数(right)を探す
ng = 0
ok = n + 1
while abs(ok - ng) > 1:
  m = (ok + ng) // 2
  if test(m, n + 1):
    ok = m
  else:
    ng = m
right = ok

ans = right - left - 1
print(ans)