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

int main()
{
	int n,inning=0;
	int p = 0, r = 0, o = 3;
	string event;

	cin >> n ;
	while (1)
	{
                        //r = ???????????????o = ??¢???????????°
		cin >> event;

		if (event == "HIT")
		{
			r++;
			if (r >= 4)                       //??????
			{
				p++;
                r=3;
			}
		}
		else if (event=="HORMRUN")
		{
			p += r + 1;
			r = 0;                            //??????????????????????????????
		}
		else if (event=="OUT")
		{
			o--;
			if (o == 0)
			{
				cout << p << endl;
				inning++;
				r = 0;
				o = 3;
				p = 0;
			}
		}

		if (n == inning) break;

	}

	return 0;
}