n, q = (int(x) for x in input().split())
s = input().rstrip()

masu_s = []
masu_g = []
for i in range(n):
	masu_s.append(s[i])
	masu_g.append(1)

for i in range(q):
	t, d = input().split()

	count = 0
	for j in range(n):
		if masu_s[j] == t:
			if d == 'R':
				if j == n-1:
					masu_g[j] = 0
				elif masu_g[j] > 0:
					count = masu_g[j]
					masu_g[j+1] += count
					masu_g[j] = 0
			elif d == 'L':
				if j == 0:
					masu_g[j] = 0
				elif masu_g[j] > 0:
					count = masu_g[j]
					masu_g[j-1] += count
					masu_g[j] = 0
			count = 0

for i in masu_g:
	count += i

print(count)