n,q=map(int,input().split())
s=" "+input()+" "
td=[input().split()for _ in[0]*q]
def test(x):
	for t,d in td:
		if s[x]==t:x+=1 if d=="R"else -1
	return x
def bs(b,g,t):
	while abs(b-g)>1:
		k=(b+g)//2
		if test(k)==t:g=k
		else:b=k
	return g
l=bs(n+1,0,0)
r=bs(0,n+1,n+1)
print(r-l-1)