import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
S = list(input())[: -1]
qs = [input().split() for _ in range(Q)]

def lcheck(x):
  i = x
  for t, d in qs:
    if S[i] == t:
      if d == "L": i -= 1
      else: i += 1
    if i in range(N): continue
    return i < 0
  return False

def rcheck(x):
  i = x
  for t, d in qs:
    if S[i] == t:
      if d == "L": i -= 1
      else: i += 1
    if i in range(N): continue
    return i >= N
  return False

ok = -1
ng = N
while ng - ok > 1:
  m = (ok + ng) // 2
  if lcheck(m): ok = m
  else: ng = m

res = N - ng

ok = N
ng = -1
while ok - ng > 1:
  m = (ok + ng) // 2
  if rcheck(m): ok = m
  else: ng = m

res -= N - ok
print(res)