N,Q=map(int,input().split())
X=str(input())
M=""
J=""
for i in range(Q):
  W,K=map(str,input().split())
  M+=W
  J+=K
S=[]
for i in range(N):
  S.append(1)
for i in range(Q):
 
  Y=0
  for e in X:
    
    if (e==M[i]) :
      if J[i]=="L":
        if Y==0:
          S[0]=0
          Y+=1
        else:
         
          S[Y-1]+=S[Y]
          S[Y]=0
          Y+=1
      if J[i]=="R":
        if Y==N-1:
          S[N-1]=0
          Y+=1
        else:
          
          S[Y+1]+=S[Y]
          S[Y]=0
          Y+=1
      
    else:
      Y+=1
ans=0
for i in range(N):
  ans+=S[i]
print(ans)