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

int main(){
	
	string sim ;
	int n;
	int base=0 , point=0 , count=0 ;
	
	cin >> n ;
	
	for( int i=0 ; i<n ;){
		cin >> sim ;
		
		if( sim == "HIT" ){
			base++;
			if( base == 4 ){
				base=3;
				point++;
			}
		}
		else if( sim == "HOMERUN" ){
			point += base+1 ;
			base=0;
		}
		else if( sim == "OUT" ){
			count++;
			if( count%3 == 0 ){
				cout << point << endl ;
				i++;
				base=0;
				point=0;
			}
		}
	}
	
return 0;
}