import sys
import numpy as np
stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str

n,q = na()
s = np.array(list(ns()))
#print(s)
m=np.ones(n+2)
#m[1:n-1]+=1
for i in range(q): 
	t,d=list(stdin.readline().split())
	#print(m)

	index=np.where(s==t)[0]
	#print(index)
	for i in index:
		if d=="R":
			m[i+2]+=m[i+1]
			m[i+1]=0
		else:
			m[i]+=m[i+1]
			m[i+1]=0
print(int(m[1:n+1].sum()))

