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)
	mm=m.copy()
	mm[np.where(s!=t)[0]+1]=0
	#print(mm)
	
	if d=="R":
		m[2:]+=mm[1:n+1]
		m-=mm
	else:
		m[:n]+=mm[1:n+1]
		m-=mm
print(int(m[1:n+1].sum()))

