from collections import defaultdict
n,q=map(int,input().split())
s=input()
m=defaultdict(list)
for i in range(n):m[s[i]]+=[i]
g=[1]*n
for i in range(q):
	t,d=input().split()
	if d=="L":
		for i in m[t]:
			if i>0:g[i-1]+=g[i]
			g[i]=0
	else:
		for i in m[t]:
			if i<n-1:g[i+1]+=g[i]
			g[i]=0
print(sum(g))