import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def count(s: String, t: String) = {
    (0 to s.length - t.length).map(n => s.drop(n)).filter(_.startsWith(t)).size
  }
  def main(args: Array[String]) {
    while(sc.hasNext) {
      val s = sc.next
      println(count(s, "JOI"))
      println(count(s, "IOI"))
    }
  }
}