#include <iostream>
#include <string>

using namespace std;

int main(){
	int n , i = 1;
	int base = 0 , sum[100] = {} , out_count = 0;
	string str;

	cin >> n;
		
	while(1){
	    
		if(i > n) break;
		cin >> str;
		
		if(out_count >= 3){
			base = 0;
			i++;
		}
		if(base >= 4){
		    sum[i]++;
		    base = base - 1;
		}
		if(str == "HIT"){base++;}
		else if(str == "OUT"){out_count++;}
		else if(str == "HOMERUN"){
		    sum[i] += base + 1;
		    base = 0;
		}
		
	}
    for(int i = 0; i < n; i++){
        cout << sum[i + 1] << endl;
    }
    
	return 0;
}