a = []
N = map(int,raw_input().split())
c = raw_input()
mem = 0
temp = 0
for i in range(N[0]):
	a.append(1)
for i in range(N[1]):
	k = 0
	td = raw_input().split()
	for ch in c:
		if td[1] == 'L':
			if ch == td[0]:
				if k == 0:
					a[0] = 0
				else:
					a[k-1] += a[k]
					a[k] = 0
		else:
			if ch == td[0]:
				if k == N[0] - 1:
					a[k] = mem
					mem = 0
				else:
					temp = a[k]
					a[k] = mem
					mem = temp
			else:
				a[k] += mem
				mem = 0
		k = k + 1
print(sum(a))
