n,q=(int(i) for i in input().split())
s=list(input())
l=[1]*n
l.insert(0,0);l.append(0)
lst=[]
for i in [0]*q:
    lst.append(tuple(input().split()))
for i in lst:
    a,b=i
    for c,d in enumerate(s):
         if a==d:
            if b=='R':
                l[c+2]+=l[c+1]
            else:
                l[c]+=l[c+1]
            l[c+1]=0
print(n-(l[0]+l[-1]))