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

cnt = dict(zip(range(N), [1] * N))
idxs = dict(zip(S, [[] for _ in range(N)]))

for i, s in enumerate(S):
  idxs[s].append(i)

for _ in range(Q):
  t, d = input().split()
  if t not in S:
    continue
  for idx in idxs[t]:
    if (idx == 0 and d == 'L') or (idx == N-1 and d == 'R'):
      cnt[idx] = 0
    else:
      tgt = idx+1 if d == 'R' else idx-1
      cnt[tgt] += cnt[idx]
      cnt[idx] = 0

print(sum(cnt.values()))