#include<string>
#include<iostream>

using namespace std;

int main()
{
	int n;	cin>>n;
	string s;
	int runner=0,out=0,score=0;
	while(cin>>s){
		if(s=="HIT"){
			runner<<=1;
			if(runner&8)runner&=~8,score++;
			runner|=1;
		}
		else if(s=="HOMERUN"){
			for(int i=0;i<3;i++){
				runner<<=1;
				if(runner&8)runner&=~8,score++;
			}
			score++;
		}
		else{
			out++;
			if(out==3)	cout<<score<<endl,runner=out=score=0;
		}
	}
	return 0;
}
#include <iostream>
#include <string>

using namespace std;

int main() {
	int point = 0, hits = 0, out = 0;
	int n; cin >> n;
	
	int i = 0;
	while (i < n) {
		string s; cin >> s;
		if (s == "HIT") {
			hits++;
			if (hits == 4) {
				point++;
				hits--;
			}
		}
		if (s == "OUT") {
			out++;
			if (out == 3) {
				hits = 0;
				out = 0;
				cout << point << endl;
				point = 0;
				i++;
			}
		}
		if (s == "HOMERUN") {
			point += hits + 1;
			hits = 0;
		}
	}
	
	return 0;
}