n,q=map(int,input().split())
s=list(input())
lis=[list(input().split()) for _ in range(q)]
cnt=0
for i in range(n):
    dp=[0 for _ in range(n)]
    dp[i]=1
    k=i
    for j in range(q):
        if s[k]==lis[j][0]:
            if lis[j][1]=="L":
                if k==0:
                    cnt+=1
                    break
                else:
                    dp[k-1]=1
                    dp[k]=0
                    k-=1
            else:
                if k==n-1:
                    cnt+=1
                    break
                else:
                    dp[k+1]=1
                    dp[k]=0
                    k+=1
print(n-cnt)