
import std.stdio, std.string;

void main() {
  string s;
  int n;
  int points = 0;
  int out_cnt = 0;
  bool runner[4];;
  readf("%d\n", &n);
  while ((s = readln.chomp), !stdin.eof) {
    switch(s) {
    case "HIT":
      if (runner[3]) points++;
      runner[3] = runner[2];
      runner[2] = runner[1];
      runner[1] = true;
      break;
    case "OUT":
      out_cnt++;
      if (out_cnt == 3) {
        writeln(points);
        out_cnt = 0;
        points = 0;
        foreach(ref r; runner) r = false;
      }
      break;
    case "HOMERUN":
      int p = 0;
      foreach(ref r; runner) {
        if (r) {
          p++;
          r = false;
        }
      }
      points += p + 1;
      break;
    default:
      break;
    }
  }
}