#include <iostream>
using namespace std;

int main() {
  int n,first,second,third,point,out;
  string str;
  while(cin >> n) {
    point = 0;
    out = 0;
    first = 0;
    second = 0;
    third = 0;
    for(int i=0;i<n;i++) {
      cin >> str;
      if(str == "HIT") {
	if(third == 1) {
	  third = 0;
	  point++;
	}
	if(second == 1) {
	  second = 0;
	  third = 1;
	}
	if(first == 1) {
	  second = 1;
	}
	first = 1;
      }
      else if(str == "OUT") {
	out++;
	if(out == 3) break;
      }
      else if(str == "HOMERUN") {
	point += 1 + first + second + third;
	first = 0;
	second = 0;
	third = 0;
      }
    }
    cout << point << endl;
  }
}