n = gets.to_i

score = 0
out_cnt = 0
base_data = 0
out_cnt_n = 0

loop do
  
  data = gets.chomp
  
  case data
  when "HIT"
    base_data += 1
    if base_data == 4
      score += 1
      base_data = 3
    end
    
  when "HOMERUN"
    score += base_data + 1
    base_data = 0
    
  when "OUT"
    out_cnt += 1
    if out_cnt == 3
      puts score
      out_cnt = 0
      base_data = 0
      score = 0
      out_cnt_n += 1
      if out_cnt_n == n
        break
      end
    end
    
  end
end