n,q=map(int,input().split())
s=input()
l=[1]*n
m=[]
for i in range(n):
    m.append(s[i])
for v in range(q):
    t,d=map(str,input().split())
    indexes = [i for i, x in enumerate(m) if x == t]
    for _ in range(len(indexes)):
        v=indexes[_]
        if d=="L":
            if v==0:
                l[0]=0
            else:
                l[v-1]+=l[v]
                l[v]=0
        else:
            if v==n-1:
                l[-1]=0
            else:
                l[v+1]+=l[v]
                l[v+1]=0
print(sum(l))