#include <iostream>

using namespace std;

int state;

int hit(int times) {
	int ret = 0;
	for (int i = 0; i < times; ++i) {
		ret += state & 1;
		state >>= 1;
	}
	return ret;
}

int main() {
	int n; cin >> n;
	for (int k = 0; k < n; ++k) {
		int out = 0, point = 0;
		state = 0;
		while (out < 3) {
			string str; cin >> str;
			if (str == "HIT") point += hit(1), state |= 4;
			else if (str == "HOMERUN") point += hit(3) + 1;
			else if (str == "OUT") ++out;
		}
		cout << point << endl;
	}
}