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 == "R" && pos >= 1 && S[pos - 1] == t
		pos - 1
	else
		pos
	end
end

head = 0
head_max = 0
tail = N + 1
tail_min = N + 1
spell.reverse.each{|t, d|
	head = move(head, t, d)
	tail = move(tail, t, d)
	if head_max < head
		head_max = head
	end
	if tail_min > tail
		tail_min = tail
	end
}

if head_max < tail_min
	puts "#{tail_min - head_max - 1}"
else
	puts 0
end
