n,q = map(int,input().split())
s = input()
t = [0]+[1]*(n)+[0]
d={}
for i in range(n):
    mo=s[i]
    if d.get(mo)==None:
        d[mo]=[]
        d[mo].append(i)
    else:
        d[mo].append(i)
for i in range(q):
    x,y = map(str,input().split())
    if d.get(x)!=None:
        L = d[x]
        if y=="L":
            L.sort()
            p=-1
        else:
            L.sort(reverse=True)
            p=1
        for j in L:
            t[j+p]+=t[j]
            t[j]=0
print(sum(t[1:n]))