n,q = map(int,input().split())
s = input()
x=[]
for a in range (0,n):
  x.append(1)
for b in range (0,q):
  t,d = map(str,input().split())
  for c in range(0,n):
    if s[c] == t and d == "L":
      if c == 0:
        x[c] = 0
      else:
        x[c-1] += x[c]
        x[c] = 0
    elif s[c] == t and d == "R":
      if c == n-1:
        x[c] = 0
      else:
        x[c+1] += x[c]
        x[c] = 0
    else:
      c += 1
  b += 1

ans=0
for m in range(0,n):
  ans += x[m]

print(ans)