N,Q=map(int,input().split())
s=input()
td=[list(map(str,input().split())) for l in range(Q)]
l=[1]*(N+2)
l[0]=0
l[N+1]=0
#print(l)
for i in range(Q):
    for j in range(N):
        if td[i][0]==s[j] and td[i][1]=='L' and l[j+1]>0:
            l[j]+=l[j+1]
            l[j+1]-=l[j+1]
            l[0]=0
            l[N+1]=0
            #print(l)
        elif td[i][0]==s[j] and td[i][1]=='R' and l[j+1]>0:
            l[j+2]+=l[j+1]
            l[j+1]-=l[j+1]
            l[0]=0
            l[N+1]=0
            #print(l)
        else:
            pass
#print(l)
print(sum(l))