#include <iostream>

using namespace std;

int main(void){
	int n;
	cin >> n;
	int times = 0;
	int hit = 0;
	int point = 0;
	int out= 0 ;
	for(;times<n;){
		string s;
		cin >> s;
		if(s=="OUT"){
			out++;
			if(out==3){
				times++;
				cout << point << "\n";
				hit = 0;
				point = 0;
				out = 0;
			}
		}else if(s=="HIT"){
			if(hit<3) hit++;
			else point++;
		}else if(s=="HOMERUN"){
			point += hit+1;
			hit = 0;
		}
	}
	return 0;
}