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 v in range(1,n+1):
        if m[v-1]!=t:
            #print(m[v-1])
            pass
        else:
            #print(v)
            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(l)
print(sum(l[1:-1]))