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

int main()
{
	string str;
	int n;
	int point=0,outcount=0,run=0;
	cin >> n;
	while(n != 0){
		cin >> str;
		if(str == "OUT"){
			outcount++;
			if(outcount == 3){
				cout << point << endl;
				point = 0;outcount=0;run=0;
				n--;
			}
		}
		else if(str == "HOMERUN"){
			point+=run+1;
			run = 0;
		}
		else if(str == "HIT"){
			run++;
			point += run/4;
			run -= run/4;
		}
	}
	return 0;
}