#include<iostream>
#include<string>

int n;
std::string s;
int cnt, pnt;
int rui;

int main()
{
	std::cin >> n;

	while( std::cin >> s )
	{
		if( s == "HIT" )
		{
			++rui;
			
			if( rui > 3 )
			{
				--rui;
				++pnt;
			}
		}
		else if( s == "HOMERUN" )
		{
			pnt += rui + 1;
			rui = 0;
		}
		else
			++cnt;

		if( cnt == 3 )
		{
			std::cout << pnt << std::endl;
			rui = cnt = pnt = 0;
		}
	}

	return 0;
}