N, Q = map(int,input().split())
S = list(input())
TD = [input().split() for _ in range(Q)]
TD = [[t,d] for t, d in TD if t in S]

res = [1]*N
for t, d in TD:
  for i in range(N):
    if res[i] == 0:
      continue
    if t == S[i]:
      if d == "L":
        if i == 0:
          res[i] = 0
          break
        res[i-1] += res[i]
        res[i] = 0
      else:
        if i == N-1:
          res[i] = 0
          break
        res[i+1] += res[i]
        res[i] = 0
print(sum(res))