#include <cstdio>
#include <iostream>
#include <string>

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

using namespace std;

int main() {
	int n;
	int base = 0, out = 0, count = 0;
	cin >> n;
	string str;
	while(1) {
		if(EOF == scanf("%s", str)) break;
		if(str == "OUT") {
			out++;
			cout << out << endl;
			if(out >= 3) {
				cout << count <<endl;
				count = out = base = 0;
				n--;
			}
		} else if(str == "HOMERUN") {
			count += base + 1;
			base = 0;
		} else {
			base++;
			if(base >= 4) {
				count++;
				base--;
			}
		}
	}
	cout << count << endl;
	return 0;
}