from copy import*
from collections import*
n,q=map(int,input().split())
d=defaultdict(list)
for k,v in enumerate(input()):
    d[v].append(k)
#print(d)
ans=deepcopy(n)
for i in range(q):
    s,t=input().split()
    if t=="L":
        l=[]
        for i in d[s]:
            if i-1>=0:
                l+=[i-1]
        d[s]=l
    else:
        l=[]
        for i in d[s]:
            if i+1<n-1:
                l+=[i+1]
        d[s]=l
    #print(d)
print(sum(len(i) for i in d.values()))