n,q=map(int,input().split())
s=input()
l=[0]
m=[]
for i in range(n):
    l.append(1)
    m.append(s[i])
l.append(0)
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[_]+1
        if l[v]==0:
            pass
        else:
            if d=="L":
                l[v-1]+=l[v]
                l[v]=0
            else:
                l[v+1]+=l[v]
                l[v+1]=0
print(sum(l[1:-1]))