#include<iostream>
using namespace std;
int main()
{
	int base,i,j,n,o,point;
	char state[8];
	cin >> n;
	for(i=0;i<n;i++)
	{
		o=base=0;
		while(o<3)
		{
			cin >> state;
			if(state == "HIT")
			{
				cout << "k" << endl;
					if(base == 3)
						point++;
					else
						base++;
			}
			else if(state ==	"HOMERUN")
			{
					cout << "k" << endl;
					base++;
					point+= base;
					base =0;
					break;
			}
			else if(state == "OUT")
					o++;
		}
		cout << point << endl;
	}
	return 0;
}