N,Q = map(int,input().split())
s = input()
q = []
for i in range(Q):
	t,d = input().split()
	if d == "L":
		d = "R"
	else:
		d = "L"
	q.append(t,d)
q.reverse()	
l, r = -1, N
for query in q:
	t,d = query[0], query[1]
	if d == "R":
		if l < N - 1 and s[l+1] == t:
			l += 1
	else:
		if r > 0 and s[r-1] == t:
			r -= 1

print(N - min(N, l+(N-r)))