
n = gets

out = 0
base = 0
point = 0
inning = 0

while inning < n.to_i do
	event = gets

	case event
	when /OUT.*/
		out += 1
	when /HOMERUN.*/
		point += 1
		point += 1 if base & 0b001
		point += 1 if base & 0b010
		point += 1 if base & 0b100
	when /HIT.*/
		base << 1
		point += 1 if base & 0b1000
	else
		print("undefined event: ", event, "\n")
	end

	if out == 3 then
		inning += 1
		print(point, "\n")
		point = 0
	end
end