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