import scala.io.StdIn.readLine

object Main extends App {
  var j=0;var i=0
  val s = readLine

  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)
}