# -*- coding: utf-8 -*-
import sys
import collections

def main():
	N, Q = map(int, input().split(" "))
	S = input()
	S = list(S)
	gorlm_num = [1] * len(S)
	
	skill = []
	for _ in range(Q):
		t, d = input().split(" ")
		#print(gorlm_num)
		tmp = [i for i, x in enumerate(S) if x == t]
		for i in tmp:
			tt = gorlm_num[i]
			gorlm_num[i] = 0
			if d == "R" and i != len(S)-1:
				gorlm_num[i+1] += tt
			if d == "L" and i != 0:
				gorlm_num[i-1] += tt
				
	ans = 0
	for i in gorlm_num:
		ans = ans + i
		
	print(ans)
	
if __name__ == "__main__":
	main()
	