N,Q = map(int,input().split())
s = input()
spell = []

for cur in range(Q):
	spell.append(list(input().split()))

state = []
for c in s:
	state.append([c,1])

for sp in spell:
	for index,st in enumerate(state):
		if(st[0] == sp[0]):
			buf = st[1]
			st[1] = 0
			if(sp[1] == 'L'):
				if(index != 0):
					state[index-1][1] += buf
			else:
				if(index != (len(state)-1)):
					state[index+1][1] += buf
sum = 0
for st in state:
	sum += st[1]

print(sum)

