import numpy as np
n, q = list(map(int, input().split()))
s = list(input())

qs = np.array([1]*(n+2))
s_dict = {}
for i, s_ in enumerate(s):
  if s_ not in s_dict.keys():
    s_dict[s_] = [i+1]
  else:
    s_dict[s_] += [i+1]

for i in range(q):
  t_, d = input().split()
  if t_ in s_dict.keys():
    qs_ = qs.copy()
    s_ = s_dict[t_]
    if d=="L":
      for j in s_:
        qs_[j-1]+=qs[j]
        qs_[j]-=qs[j]
    else:
      for j in s_:
        qs_[j+1]+=qs[j]
        qs_[j]-=qs[j]
    qs = qs_
print(sum(qs[1:-1]))