#include <iostream>
#include <string>
using namespace std;

//0103
int main(){
	int n;
	string s;

	cin >> n;
	int point=0;
	int out=0;
	int base[3]={0, 0, 0};

	while(cin >> s){

		if(s=="HIT"){
			if(base[2]==1){
				++point;
				base[2]=0;
			}
			if(base[1]==1){
				base[2]=1;
				base[1]=0;
			}
			if(base[0]==1){
				base[1]=1;
				base[0]=0;
			}
			base[0]=1;

		}else if(s=="HOMERUN"){
			for(int i=0; i<3; ++i){
				point += base[i];
			}
			point++;
			base[0]=0;
			base[1]=0;
			base[2]=0;

		}else{
			++out;
			if(out>=3){
				cout << point << endl;
				point=0;
				out=0;
				base[0]=0;
				base[1]=0;
				base[2]=0;
				continue;
			}
		}
		
	}
	return 0;
}