X = list(map(int, input().split(" ")))
N = X[0]
Q = X[1]
S = [i for i in input()]

T = [0]*Q
D = [0]*Q
for i in range(Q):
	X = input().split(" ")
	T[i] = X[0]
	D[i] = X[1]

golems = [1]*N
for i in range(Q):
	if D[i] == "L":
		for j in range(N):
			if S[j] == T[i] and golems[j] > 0:
				if j == 0:
					pass
				else:
					golems[j-1] += golems[j]
				golems[j] = 0
	else:
		for j in range(N):
			j = N - j - 1
			if S[j] == T[i] and golems[j] > 0:
				if j == (N-1):
					pass
				else:
					golems[j+1] += golems[j]
				golems[j] = 0

print(sum(golems))