df = [0, 0, 0]
gets.to_i.times do
  o = 0
  p = 0
  f = df.dup
  until o == 3
    case gets.chomp
    when 'HIT'
      p += f.pop
      f.unshift 1
    when 'HOMERUN'
      p += f.reduce(:+) + 1
      f = df.dup
    else
      o += 1
    end
  end
  puts p
end