N, Q = map(int, input().split())
s=list(input())
sNum=[0]*N
sum=0
for i in range(N):
  sNum[i]=1 #全ての箱に1体のゴーレム
for j in range(Q):
  t2, d2 = input().split()
  for i in range(N):
    if t2==s[i]:
      if d2=="R":
        if i==N-1:
          sum+=sNum[i]
        else:
          sNum[i+1]+=sNum[i]
        sNum[i]=0
      else:
        if i==0:
          sum+=sNum[i]
        else:
          sNum[i-1]+=sNum[i]
        sNum[i]=0

print(N-sum)