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