$<.gets.to_i.times do
	point = 0
	out = 0
	runner = 0

	while out < 3
		case $<.gets.chomp
		when 'HIT'
			runner == 3 ? point += 1 : runner += 1
		when 'OUT'
			out += 1
		when 'HOMERUN'
			point += runner + 1
			runner = 0
		end
	end

	p point
end