n,q = map(int,input().split())
s = list(input())
g = [1]*n
for i in range(q):
    x,y = input().split()
    if y=="R":
        for j in range(n-1):
            if s[j]==x:
                g[j+1]+=g[j]
                g[j]=0
        if s[-1]==x: g[-1]=0
    else:
        for j in range(n):
            if s[j]==x:
                if j==0:
                    g[j]=0
                else:
                    g[j-1]+=g[j]
                    g[j]=0
print(sum(g))