import std.stdio,std.conv,std.string;

void main(){
    foreach(_;0..readln.chomp.to!int){
        int point,base,_out;
        while(1){
            final switch(readln.chomp){
                case "HIT":
                    if(base==3)++point;
                    else ++base;
                    break;
                case "HOMERUN":
                    point+=base+1;
                    base=0;
                    break;
                case "OUT":
                    ++_out;
                    break;
            }
            if(_out==3)break;
        }
        point.writeln;
    }
}