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-1]+=dp[j]
            else:
                if j!=n-1:
                    dp[j+1]+=dp[j]
            dp[j]=0
print(sum(dp))