n, q = map(int, input().split())
s = list(str(input()))
dic ={}
for _ in s:
  dic[_] = [i for i, x in enumerate(s) if x == _]
g = [1] * n
for i in range(q):
  t, d = map(str, input().split())
  if t not in dic: continue
  if d == "L":
    dif = -1
  else:
    dif = 1
  for j in dic[t]:
    if j + dif < 0 or j + dif > n-1:
      g[j] = 0
    else:
      g[j + dif] = g[j + dif] + g[j]
      g[j] = 0
print(sum(g))