n,q = map(int, input().split())
s = list(input())
g = [1] * (n+2)
t = []
d = []
for i in range(q):
	td = input().split()
	t.append(td[0])
	if td[1] == 'L':
		d.append(-1)
	else:
		d.append(1)
tc = {c:[] for c in set(s+t)}
for i in range(n):
	tc[s[i]].append(i)

for i in range(q):
	for j in tc[t[i]]:
		g[j+1+d[i]] += g[j+1]
		g[j+1] = 0
		g[0] = 0
		g[-1] = 0


print(sum(g))