N,Q = map(int,input().split())
s = input()
d,deans = dict(),0
for i in s:
	d[i] = str()
for i in range(Q):
	p=input().split()
	d[p[0]] += p[1]
for i in range(len(s)):
	for j in d[s[i]]:
		if j == 'R':
			i = i + 1
		elif j == 'L':
			i = i - 1
		if (i<0)|(i>=len(s)):
			deans += 1
			break
print(len(s)-deans)