#include <iostream>
#include <string>

int main(){
    int hit, out, score, data_set_num;
    std::string event;
    cin >> data_set_num;


    while(data_set_num--){
        cin >> event;
        if(event == "HIT"){
            ++hit;
            if(hit == 4){
                ++score;
                hit = 3;
            }
        }else if(event == "HOMERUN"){
            score += (hit + 1);
            hit = 0;
        }else if(event == "OUT"){
            ++out;
        }

        if(out == 3){
            std::cout << score << std::endl;
            hit = 0;
            core = 0;
        }
    }

    return 0;
}