N, Q = map(int, input().split())
S = ' ' + input() + ' '

ps = [0, N+1]
dirs = { 'L': -1, 'R': 1 }
QS = [input().split() for _ in range(Q)]
def drop(p):
  for t, d in QS:
    if S[p] == t:
      p = p + dirs[d]
      if p == 0 or p == N+1:
        return 1 if p == N+1 else -1
  return 0

# 二分探索
f = 0
t = N+1
while f + 1 < t:
  mid = f + (t-f)//2
  ret = drop(mid)
  if ret != -1:
    t = mid
  else:
    f = mid
p1 = f

f = 0
t = N+1
while f + 1 < t:
  mid = f + (t-f)//2
  ret = drop(mid)
  if ret == 1:
    t = mid
  else:
    f = mid
p2 = f
print(max(0, p2-p1))