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

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