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

int main() {
	string str;
	bool first = false, second = false, third = false;
	int out = 0, points = 0;
	int n;

	cin >> n;
	for(int i = 0; i < n;) {
		cin >> str;

		if(str == "HIT") {
			if(third == true)
				points++;

			third = second;
			second = first;
			first = true;
		}

		else if(str == "OUT") {
			out++;
			if(out == 3) {
				out = 0;
				first = second = third = false;
				cout << points << endl;
				points = 0;
				i++;
				continue;
			}
		}

		else if(str == "HOMERUN") {
			points++;
			if(first) points++;
			if(second) points++;
			if(third) points++;
			first = second = third = false;
		}
	}
}