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

l = np.array([1] * (N+2))

dic = {}

for c in s:
	if not c in dic:
		dic[c] = np.array([i for i,c2 in enumerate(s) if c == c2])

for t,d in td:
	if not t in s:
		continue
	indeces = dic[t]
	if d == 'L':
		ap = l[indeces+1]
		l[indeces+1] = 0
		l[indeces] += ap
	else:
		ap = l[indeces+1]
		l[indeces+1] = 0
		l[indeces+2] += ap

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



