n,q= map(int,input().split())
s=input()
li=[1 for i in range(n)]
for i in range(q):
    t,d=input().split()
    if d =="R":
        d=1
    else:
        d=-1
        
    for j in range(len(s)):
        if s[j]==t:
            if d+j<0:
                li[j]=0
            elif d+j==n:
                li[j]=0
            else:
                li[j+d]+=li[j]
                li[j]=0
                
print(sum(li))
    