N, Q = map(int, input().split())
s = input()
S = [1] * N
for i in range(Q):
	t, d = input().split()
	for j in range(N):
		if s[j] == t:
			if d == "R" and j < N - 1:
				S[j + 1] += S[j]
			elif d == "L" and j > 0:
				S[j - 1] += S[j]
			S[j] = 0
print(sum(S))
