N,Q=map(int,input().split())
s=[i for i in input()]
ans=[1 for i in range(N)]
for i in range(Q):
    t,d=map(str,input().split())
    T=s.copy()
    while t in T:
        
        
        if d=='R':
            if T.index(t)!=len(T)-1:
                ans[T.index(t)+1]+=ans[T.index(t)]
        
        if d=='L':
            if T.index(t)!=len(T)-1:
                ans[T.index(t)-1]+= ans[T.index(t)]
        ans[T.index(t)]=0
        T[T.index(t)]='Done'
        
print(sum(ans))