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

int main() {
	int n;
	int score=0;
	int count=0;
	int base=0;
	string d;
	cin>>n;
	for(int i=0;i<n;i++){
		while(true){
			cin>>d;
			if(d=="HIT"){
				base++;
				if(base==4){
					score++;
					base--;
				}
			}
			else if(d=="HOMERUN"){
				score=score+base+1;
				base=0;
			}
			else if(d=="OUT"){
				count++;
				if(count==3){
					count=0;
					cout<<score<<endl;
					score=0;
					base=0;
					break;
				}
			}
		}
	}
	return 0;
}
