actions = []
while line = gets
  line.chomp!
  actions << line
end

inig = actions.shift.to_i
scores = []
score = 0
out = 0
rui = 0

while inig > 0
  action = actions.shift

  if action == "HIT"
    rui += 1
  end
  if rui > 3
    score += 1
    rui = 3
  end
  if action == "HOMERUN"
    score += (rui + 1)
    rui = 0
  end

  if action == "OUT"
    out += 1
  end
  if out >= 3
    inig -= 1
    out = 0
    scores << score
    score = 0
  end
  if actions.count <= 0
    break
  end
end

scores.each {|s| puts "#{s}\n"}