N,Q = list(map(int,input().split()))
s = input()

t = ["a"]*Q
d = ["b"]*Q
for i in range(Q):
	t[i],d[i] = input().split()
c = [1]*N
flux = [0]*N

for i in range(Q):
	flux = [0]*N
	for j in range(N):
		if s[j] == t[i] and d[i] == "R":
			flux[j] += -c[j]
			if j != N-1:
				flux[j+1] += c[j]
		if s[j] == t[i] and d[i] == "L":
			flux[j] = -c[j]
			if j != 0:
				flux[j-1] += c[j]
	for j in range(N):
		c[j] += flux[j]
	#print(c)
ans = sum(c)
print(ans)
