N,Q = map(int,input().split())
s = input()
spells = []
for _ in range(Q):
	c,side = input().split()
	spells.append([c,side])
	
#print(spells)

index = {}
line = {}
for i in range(N):
	line[i] = [i,1]
	if s[i] in index:
		index[s[i]].append(line[i])
	else:
		index[s[i]] = [line[i]]
		
#print(index)
#print(line)

for spell in spells:
	c = spell[0]
	side = spell[1]
	
	if c not in s:
		continue
	
	for indexNum in index[c]:
		i = indexNum[0]
		n = indexNum[1]
		if i == 0 and side == 'L':
			line[i][1] = 0
			#print("0del",i)
			#print(line)
		elif i == N-1 and side == 'R':
			line[i][1] = 0
			#print("Ndel",i)
			#print(line)
		else:
			if side == 'L':
				num = line[i][1]
				line[i-1][1] += num
				line[i][1] = 0
				#print("l move",i)
				#print(line)
			else:
				num = line[i][1]
				line[i+1][1] += num
				line[i][1] = 0
				#print("r move",i)
				#print(line)
				
anss = []
for indexNum in line.values():
	anss.append(indexNum[1])
	
#print(anss)
print(sum(anss))