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

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

def check(pos)
	SPELL.each{|t, d|
		if S[pos] == t
			if d == "L"
				pos -= 1
				if pos == 0
					return false
				end
			else
				pos += 1
				if pos == N + 1
					return false
				end
			end
		end
	}
	return true
end

#p (1..N).collect{|pos| check(pos)}

head = (1..N).bsearch{|pos|
	check(pos)
}

if head
	tail = N - (0...N).bsearch{|pos|
		check(N - pos)
	}
	puts "#{tail - head + 1}"
else
	puts "0"
end

