N,Q = map(int,input().split(" "))
s_lst = list(input().rstrip())

pos_cnt=[1 for _ in range(N+2)]
c_ind_dict = {c:[] for c in set(s_lst)}
for i,c in enumerate(s_lst):
	c_ind_dict[c].append(i+1)

for _ in range(Q):
	c,d = input().split(" ")
	if c not in c_ind_dict.keys():
		continue
	for ind in  c_ind_dict[c]:
		if d == "L":
			pos_cnt[ind - 1] += pos_cnt[ind]
			pos_cnt[ind] = 0
		else:
			pos_cnt[ind + 1] += pos_cnt[ind]
			pos_cnt[ind] = 0

print(sum(pos_cnt[1:N+1]))