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

int main()
{
	int n,inning=0;
	int inningp[40] = {0};
	string ivent;

	cin >> n ;
	while (1)
	{
		int r=0, p=0, o=3;                        //r = ???????????????p = ?????????o = ??¢???????????°
		while (o)
		{
			cin >> ivent;

			if (ivent == "HIT")
			{
				r++;
				if (r >= 4)                       //??????
				{
					p++;
				}
			}

			else if (ivent=="HORMRUN")
			{
				if (r >= 4)                       //?????? = ???????????? + ????????????(1???)
				{
					p += 4;
				}
				else
				{
					p += r + 1;
				}
				r = 0;                            //??????????????????????????????
			}
			else if (ivent=="OUT")
			{
				o--;
			}
		}

		inningp[inning] = p;                      
		inning++;
		if (n == inning) break;

	}

	for (int i = 0; i < n; i++)
	{
		cout << inningp[i] << endl;
	}

	return 0;
}