N, Q = [int(i) for i in input().split()]
g = [1] * N

s = input()
dict = {}
for i in range(N):
  if s[i] not in dict:
    dict[s[i]] = []
  dict[s[i]].append({ "L": i - 1, "R": i + 1, "P": i })

for i in range(Q):
  t_i, d_i = input().split()
  if t_i not in dict:
    continue
  l = dict[t_i] if d_i == "L" else reversed(dict[t_i])
  for x in l:
    if x[d_i] < 0:
      g[x["P"]] = 0
      continue
    elif x[d_i] >= N:
      g[x["P"]] = 0
      continue
    else:
      g[x[d_i]] += g[x["P"]]
      g[x["P"]] = 0

print(sum(g))