# -*- 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)
		ttmp = S.count(t)
		ttmp_sub = 0
		for _ in range(ttmp):
			try :
				tmpS = S[ttmp_sub+1:]
				ins = tmpS.index(t)
				ttmp_sub += ins
			except : a = "a"
			else : a = "a"
				
			#print(ins)
				
			tt = gorlm_num[ins]
			gorlm_num[ins] = 0
			if d == "R" and ins != len(S)-1:
				gorlm_num[ins+1] += tt
			if d == "L" and ins != 0:
				gorlm_num[ins-1] += tt
				
	ans = 0
	for i in gorlm_num:
		ans = ans + i
		
	print(ans)
	
if __name__ == "__main__":
	main()
	