i=gets.to_i
d=[]
o=0
n=0
while o<i*3
  case gets.chomp
  when "HIT"
    if d.size==3
      d.shift
      n+=1
    end

    d.push(1)
  when "OUT"
    o+=1

    if o%3==0
      puts n
      n=0
      d=[]
    end
  when "HOMERUN"
    n+=d.size+1
    d=[]
  end
end