import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val b = new ArrayBuffer[Int]
  val n = readInt
  var score = 0
  var out = 0
  var hit = 0
  for(i<-1 to n) {
    hit=0
    out=0
    score=0
    while(out!=3) {
      val s = readLine
      if(s=="OUT") out += 1
      else if(s=="HIT") {
        if(hit==3) score += 1
        else hit += 1
      } else {
        score = score+hit+1
        hit = 0
      }
    }
    b += score
  }
  println(b.mkString("\n"))
}