n,Q =map(int,input().split())
S = input()
G =[1]*n

for i in range(Q):
    t,d =map(str,input().split())
    if d =="L":
        if S[0]==t:
            G[0]=0
        for j in range(1,n):
            if S[j]==t:
                G[j-1]+=G[j]
                G[j]=0
    else:
        if S[n-1]==t:
            G[n-1]=0
        for m in range(1,n):
            k = n-1-m
            if S[k]==t:
                G[k+1]+=G[k]
                G[k]=0            

print(sum(G))