N,Q = map(int,input().split(' '))
s = input()
td = [input().split(' ') for i in [0]*Q]

l = [1] * (N+2)

dic = {}

for t,d in td:
	if not t in dic:
		dic[t] = [i for i,c in enumerate(s) if c == t]
	indeces = dic[t]
	if d == 'L':
		for index in indeces:
			l[index] += l[index+1]
			l[index+1] = 0
	else:
		for index in indeces[::-1]:
			l[index+2] += l[index+1]
			l[index+1] = 0

print(sum(l[1:-1]))



