from collections import defaultdict
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = input()
pos = defaultdict(list)
for i in range(N):
  x = s[i]
  pos[x].append(i)

golem = [1]*N
for _ in range(Q):
  t, d = input().split()
  if d == 'R':
    for i in pos[t]:
      x = golem[i]
      golem[i] = 0
      if i+1 <= N-1:
        golem[i+1] += x
  elif d == 'L':
    for i in pos[t]:
      if golem[i] == 0:
        continue
      x = golem[i]
      golem[i] = 0
      if i-1 >= 0:
        golem[i-1] += x
print(sum(golem))