N, Q = map(int, input().split())
S = list(input())
TD = [tuple(input().split()) for _ in range(Q)]
G = [1 for _ in range(N)]

for td in TD:
	for i, s in enumerate(S):
		if s == td[0]:
			if "L" == td[1]:
				if 0 == i:
					G[i] = 0
				else:
					G[i-1] += G[i]
					G[i] = 0
			else:
				if N-1 == i:
					G[i] = 0
				else:
					G[i+1] += G[i]
					G[i] = 0
print(sum(G))
