#include <iostream>
#include <vector>
using namespace std;
int p, out;
int main(){
  int t;
  cin >> t;
  vector<int> v;
  string s;
  while(cin >> s){
    if(s == "HIT"){
      if(v.size()<3)v.push_back(0);
      else p++;
    }else if(s == "OUT"){
      out++;
      if(out == 3){
	cout << p << endl;
	p = out = 0;
	v.clear();
      }
    }else{
      p += v.size() + 1;
      v.clear();
    }
  }
  return 0;
}