#include <cstdio>
#include <cstring>

int singlehit(char *base, int score);
int homerun(char *base, int score);

int main(void)
{
    int number;
    scanf("%d", &number);
    
    char event[10];
    int out_num;
    char base[4];
    while (number != -1){
        int score = 0;
        for (int i = 0; i < 4; i++){
            base[i] = '0';
        }
        for (out_num = 0; out_num != 3;){
            scanf("%s", event);
            if (strcmp(event, "HIT") == 0){
                score = singlehit(base, score);
            }
            else if (strcmp(event, "HOMERUN") == 0){
                score = homerun(base, score);
            }
            else {
                out_num++;
            }
        }
        printf("%d\n", score);
        number--;
    }
    
    return (0);
}

int singlehit(char *base, int score)
{
    base[1]++;
    if (base[1] == '2'){
        base[2]++;
        base[1]--;
    }
    if (base[2] == '2'){
        base[3]++;
        base[2]--;
    }
    if (base[3] == '2'){
        score++;
        base[3]--;
    }
    
    return (score);
}

int homerun(char base[], int score)
{
    for (int i = 0; i < 4; i++){
        if (base[i] == '1'){
            score++;
            base[i] = '0';
        }
    }
    score++;
    return (score);
}