n,q=map(int,input().split())
s=list(input())
dp=[1 for i in range(n)]
for i in range(q):
    t,d=input().split()
    for j in range(n):
        if s[j]==t:
            if d=="L":
                if j==0:
                    dp[j]=dp[j]-dp[j]
                else:
                    dp[j-1]=dp[j]+dp[j-1]
                    dp[j]=dp[j]-dp[j]
            else:
                if j==n-1:
                    dp[j]=dp[j]-dp[j]
                else:
                    dp[j+1]=dp[j]+dp[j+1]
                    dp[j]=dp[j]-dp[j]
ans=0
for i in range(n):
    ans+=dp[i]
print(ans)