#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b=0;
  int out=0,point=0;
  string c;
  cin>>a;
  while(true){
    if(a==0) break;
    cin>>c;
    if(c=="HIT"){
      b++;
      if(b==4){
	point++;
	b--;
      }
    }
    if(c=="OUT"){
      out++;
      if(out==3){
	a--;
	out=0;
	cout<<point<<"\n";
	point=0;
	b=0;
      }
    }
    if(c=="HOMERUN"){
      point=point+b+1;
      b=0;
    }
  }
}

