N, Q = map(int, input().split())
S = list(input())
TD = [tuple(input().split()) for _ in range(Q)]

TEST = [0, 0, 0, 1, 1, 1, 0, 0]

def bs_l(f, s, e):
	if s==e:
		return s if(1==f(s)) else s+1

	c = (s+e)//2
	if f(c):
		#左
		return bs_l(f, s, c if c == s else c-1)
	else:
		#右
		return bs_l(f, c if c == e else c+1, e)

def bs_r(f, s, e):
	if s==e:
		return s if(1==f(s)) else s-1

	c = (s+e)//2
	if not f(c):
		#左
		return bs_r(f, s, c if c == s else c-1)
	else:
		#右
		return bs_r(f, c if c == e else c+1, e)

def isAlive_l(c):
	for t, d in TD:
		if S[c] == t:
			c += 1 if "R" == d else -1
			if c < 0:
				return False
	return True

def isAlive_r(c):
	for t, d in TD:
		if S[c] == t:
			c += 1 if "R" == d else -1
			if N <= c:
				return False
	return True

S, E = bs_l(isAlive_l, 0, N-1), bs_r(isAlive_r, 0, N-1)
print(E-S+1)
