#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;
 
int main(void){
  int out = 0, base = 0,point = 0;
  int n;
  cin>>n;
  int i=0;
  while(true){
    i++;if(i>20)break;
    string s;
    cin>>s;
    //cout<<s<<endl;
     
    if(s=="OUT"){
      out++;
      //cout<<out<<endl;
      if(out==3){
    //cout<<"poin"<<endl<<endl;;
    cout<<point<<endl;
    point=0;
    out = 0;
    base = 0;
    n--;
    if(n==0)break;
      }
    }
    else if(s=="HIT"){
      base++;
      //cout<<base<<endl;
      if(base>=4){
    //cout<<base<<" "<<point<<endl;
    point++;
    base--;
    //cout<<base<<" "<<point<<endl;
      }
    }
     
    if(s=="HOMERUN"){
      point += base+1;
      base = 0;
              
    }
     
  }
  return 0;
}