N,Q=map(int,input().split())
s=input()
t=[0 *Q]
d=[0 *Q]

go=[1 *N]
ans=0

for i in range(Q):
   t[i],d[i]=input().split()

for i in range(Q):
    for h in range(N):
        if t[i]==s[h] and go[h]!=0:
            if (h==0 and d[i]=="L") or (h==N-1 and d[i]=="R"):
                ans+=go[h]
                go[h]=0
            else:
                go[h+1 if d[i]=="R" else h-1]+=go[h]
                go[h]=0
print(N-ans)
