plant, nobiro, tidime = gets.split(' ').map(&:to_i)
days = gets.to_i

days.times do
	order = gets
	
	case order
	when "nobiro\n"
		plant += nobiro
	when "tidime\n"
		plant += tidime
	when "karero\n"
		plant = 0
	end
	if plant < 0
		plant = 0
	end
end
puts plant
