n,q=list(map(int,input().split()))
s=[[' ',0]]
s+=[[c,1]for c in input()]
s+=[[' ',0]]
for i in range(q):
	t,d=input().split()
	if d=='L':
		for j in range(1,n+1):
			if s[j][0]==t:
				x=s[j][1]
				s[j][1]=0
				s[j-1][1]+=x
	else:
		for j in range(1,n+1):
			if s[j][0]==t:
				x=s[j][1]
				s[j][1]=0
				s[j+1][1]+=x
print(sum([m[1] for m in s[1:-1]]))