#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	int n, i, score=0, hit=0, out=0;
	string s;
	
	cin >> n; cin.get();
	
	for (i=0; i<n;) {
		getline(cin, s);
		if (s == "HIT") {if (++hit == 4) {score++; hit--;}}
		else if (s == "HOMERUN") {score += hit+1; hit = 0;}
		else if (s == "OUT") {if (++out == 3) {out=0; hit = 0; cout << score << endl; score=0; i++;}}
	}
	return 0;
}