#include <iostream>
#include <string>

using namespace std;

int main(){
        string t;
        int i,r,score,o,ini;
        score = 0;
        cin >> ini;
        for(i=0;i<ini;i++){
        while(1){
        cin >> t;
        if(t == "HIT"){
                r++;
                if(r == 4){
                        score++;
                        r--;
                }
        }else if(t == "OUT"){
                o++;
                if(o == 3){
                        r = o = 0;
                        break;
                }
        }else if(t == "HOMERUN"){
                score += r + 1;
                r = 0;
        }
        }
        cout << score << endl;
        score = 0;
        }
return 0;
}