n,q = map(int,input().split())
s = input()
x=[]
for a in range(0,n+2):
  x.append(1)
x[0]=0
x[n+1]=0
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":
        x[c] += x[c+1]
        x[c+1] = 0
    elif s[c] == t and d == "R":
        x[c+2] += x[c+1]
        x[c+1] = 0
    else:
      c += 1
ans = n-x[0]-x[n+1]
print(ans)