N, Q = gets.split(/ /).collect{|n| n.to_i}
S = ['-'] + gets.strip.split(//)

spell = []
Q.times{
	spell << gets.strip.split(/ /)
}

def move(pos, t, d)
	if d == "L" && pos <= N && S[pos + 1] == t
		pos + 1
	elsif d == "L" && pos == N && S[N] == t
		pos + 1
	elsif d == "R" && pos >= 1 && S[pos - 1] == t
		pos - 1
	elsif d == "R" && pos == 1 && S[1] == t
		pos - 1
	else
		pos
	end
end

head = 0
tail = N + 1
#p [head, tail]
spell.reverse.each{|t, d|
	head = move(head, t, d)
	tail = move(tail, t, d)
#	p [head, tail]
}

if head < tail
	puts "#{tail - head - 1}"
else
	puts 0
end
