n, q = map(int,input().split())
s = input()
f=[]
for i in range(n):
  f.append([s[i],1])
for i in range(q):
  t, d = map(str,input().split())
  for j in range(n):
    if f[j][0] == t:
      w = f[j][1]
      if d == "L":
        if j == 0:
          f[j][1] -= w
        else:
          f[j][1] -= w
          f[j-1][1] += w
      else:
        if j == n-1:
          f[j][1] -= w
        else:
          f[j][1] -= w
          f[j+1][1] += w
f = [x[1] for x in f]
print(sum(f))