n, q  = map(int, input().split())
s = input()
l = [1] * n
for i in range(q):
  ln = [0] * n
  t, d = input().split()
  for j in range(n):
    if s[j] == t:
      if j < n-1 and d == "R":
        ln[j+1] += l[j]
      elif j > 0 and d == "L":
        ln[j-1] += l[j]
    else:
      ln[j] += l[j]
  l = ln

print(sum(l))
