actions = $stdin.gets.split('\n')
inig = actions.slice(0).to_i
scores = []
while inig >= 0
  score = 0
  outs = 0
  rui = 0

  action = actions.slice(0)
  rui += 1 if action == 'HIT'
  if action == 'HOMERUN'
    score += rui
    rui = 0
  end
  score += (rui -= 3) if rui > 3
  outs += 1 if action == 'OUT'
  if outs >= 3
    inig -= 1
    outs = 0
    scores << score
    score = 0
  end
end

scores.each {|s| puts s+'\n'}