left=gets.to_i
out,runner,score=0,0,0
while left>0
  judge=gets.chomp
  case judge
  when "HIT" then
    runner+=1
    if runner>3 then
      runner-=1
      score+=1
    end
  when "OUT" then
    out+=1
    if out>=3 then
      puts score
      runner,score,out=0,0,0
      left-=1
    end
  when "HOMERUN" then
    score+=(runner+1)
    runner=0
  end
end