from collections import*
n,q=map(int,input().split())
s=input()
f=defaultdict(list)
for i,c in enumerate(s):
    f[c].append(i)
l=[1]*n
for _ in range(q):
    t,d=input().split()
    for i in f[t]:
        if d=='L':
            if i-1>=0:
                l[i-1]+=l[i]
        else:
            if i+1<n:
                l[i+1]+=l[i]
        l[i]=0
print(sum(l))