num = gets.chomp.to_i
out_time = 0
array = []
score = 0
while true
  str = gets.chomp
  return if str.nil?
  case str
  when "HIT"
    array << 1
    if array.length >= 4
      array.delete_at(array.length - 1)
      score += 1
    end
  when "HOMERUN"
    score += array.length + 1
    array = []
  when "OUT"
    out_time += 1
  end
  if out_time == 3
    puts score.to_s
    out_time = 0
  end
end