n, q = map(int, input().split())
s = "#" + input() + "#"
TD = [input().split() for _ in range(q)]

def test(x):
  for t, d in TD:
    if s[x] == t:
      if d == "L":
        x -= 1
      else:
        x += 1
  return x

def bisrch(ng, ok, C):
  while abs(ng-ok) > 1:
    mid = (ng+ok)//2
    if test(mid) == C:
      ok = mid
    else:
      ng = mid
  return ok

l = bisrch(n+1, 0, 0)
r = bisrch(0, n+1, n+1)
ans = r-l-1
print(ans)