object Main {
    def a(s: String): List[String] = {
        if (s.isEmpty) Nil
        else {
            val (x, y) = s.span(_ != 'O')
            x :: a(y.tail)
        }
    }
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.toList.tail.map(_.head).mkString
        a(in).grouped(3).map(_.flatten).map(x => x.size - (3 to 0 by -1).find(y => x.endsWith("H"*y)).get).foreach(println)
    }
}