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

void hit();
void homerun();
void out();
void is_end_of_game();

int inning = 0;										// イニング数
int first = 0, second = 0, third = 0;				// 0...走者無し　1...走者有り
int runs = 0, outs = 0;								// 1イニング毎のアウト数と得点
bool end_of_game = false;							// trueで試合終了
vector<int> score_board;							// スコアボード

int main()
{
	string event;
	cin >> inning;
	while(true) {
		cin >> event;
		if (event=="HIT")
			hit();
		else if (event=="HOMERUN")
			homerun();
		else if (event=="OUT")
			out();
		else {
			cout << "error; wrong order\n";
			return -1;
		}
		if(end_of_game)
			break;
	}
	for(int i=0;i<score_board.size();i++)
		cout << score_board[i] << '\n';

	return 0;
}

void hit()
{
	if(third==1) {
		third = 0;
		runs++;
	}
	if(second==1) {
		second = 0;
		third =1;
	}
	if(first==1) 
		second = 1;
	first = 1;
}

void homerun()
{
	runs += (first + second + third + 1);
	first = second = third = 0;
}

void out()
{
	outs++;
	if(outs==3) {
		score_board.push_back(runs);
		first = second = third = 0;
		outs = 0;
		runs = 0;
	}
	is_end_of_game();
}

void is_end_of_game()
{
	if(score_board.size()==inning)
		end_of_game = true;
}