#include<iostream>
#include<deque>
#include<string>

int n;
std::string s;
int cnt, pnt;
std::deque<bool> deq;

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

	while( std::cin >> s )
	{
		if( s == "HIT" )
		{
			deq.push_back( true );
			
			if( deq.size() > 3 )
			{
				deq.pop_back();
				++pnt;
			}
		}
		else if( s == "HOMERUN" )
		{
			pnt += deq.size() + 1;
			deq.clear();
		}
		else
			++cnt;

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

	return 0;
}