import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.foreach { s=>
    var j=0;var i=0

    for(k <- 0 until s.length-2) {
      if(s(k) == 'J' && s(k+1) == 'O' && s(k+2) == 'I') j += 1
      if(s(k) == 'I' && s(k+1) == 'O' && s(k+2) == 'I') i += 1
    }
    println(j)
    println(i)
  }
}