#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int n,hitcount,outcount,score;
    hitcount=0;
    outcount=0;
    score=0;
    cin>>n;
    for (int i=0;i<n;i++) {
        while(cin>>s) {
            if (s=="HIT") {
                hitcount++;
                if (hitcount==4) {
                    score++;
                    hitcount=3;
                }
            } else if (s=="HOMERUN") {
                score=score+hitcount+1;
                hitcount=0;
            } else if (s=="OUT") {
                outcount++;
                if (outcount==3) {
                    cout << score << endl;
                    score=0;
                    outcount=0;
                    hitcount=0;
                }
            }
        }
    }
}

