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

res = [1]*N
for _ in range(Q):
  t, d = input().split()
  for i in range(N):
    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))