#include<iostream>
#include<string>

using namespace std;

int main(){
	int n,ct, score, out,run;
	string x;
	cin >> n;
	while (1){
		while (1){
			cin >> x;
			if (x == "OUT"){
				out++;
			}
			if (x == "HOMERUN"){
				score+=(run+1);
				run = 0;
			}
			if (x == "HIT"){
				run++;
			}
			if (run > 4){
				run--;
				score++;
			}
			if (out == 3){
				cout << score << endl;
				ct++;
				break;
			}
		}
		if (ct == n)break;
	}
	return 0;

}