#include <iostream>
using namespace std;
int main( void )
{
	int n;
	cin >> n;

	int i = 0;

	int point = 0;
	int hit = 0;
	int now = 0;
	while ( i < n )
	{
		string s;
		cin >> s;
		if ( s == "OUT" )
		{
			now++;
		}
		else if ( s == "HIT" )
		{
			if ( hit >= 3 )
				point++;
			hit++;
		}
		else if ( s == "HOMERUN" )
		{
			point += hit + 1;
			hit = 0;
		}

		if ( now >= 3 )
		{
			cout << point << endl;
			now = 0;
			point = 0;
			hit = 0;
			i++;
		}
	}
	return 0;
}