result = []
gets.chomp.to_i.times do |inning|
  score = 0
  out = 0
  runner = 0
  while out < 3
    event = gets.chomp
    case event
    when "HIT"
      runner += 1
    when "HOMERUN"
      score += runner + 1
      runner = 0
    when "OUT"
      out += 1
    end
    if runner == 4
      score += 1
      runner = 3
    end
  end
  result[inning] = score
end

puts result