#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int n;
  cin >> n;
  string s;
  int stp = 0, out = 0, run = 0, ans = 0;

  while(stp < n * 3){
    cin >> s;
    if(s == "OUT"){
      out++;
      stp++;
    }
    else if(s == "HIT"){
      if(run == 3) ans++;
      else run++;
    }
    else{
      ans += run + 1;
      run = 0;
    }
    if(out == 3){
      cout << ans << endl;
      out = 0;
      run = 0;
      ans = 0;
    }
  }
}

