#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
  int n;
  cin >> n;
  string t;
  queue<string> que;
  while(cin >> t) que.push(t);
  int out=0,run=0,point=0;
  while(!que.empty()) {
    if(n==0) break;
    string s=que.front();
    que.pop();
    if(s=="HIT") {
      run++;
      if(run==4) {
	point++;
	run=3;
      }
    } else if(s=="HOMERUN") {
      run++;
      point+=run;
      run=0;
    } else {
      out++;
      if(out==3) {
	n--;
	run=0;
	out=0;
	cout << point << endl;
	point=0;
      }
    }
  }
  return 0;
}
