import System.IO (isEOF)

main = do
    quit <- isEOF
    if quit then return () else do
        line <- getLine
        let
            (joi,ioi) = count line
        print joi
        print ioi
        main

count :: String -> (Int,Int)
count s = count' s 0 0
    where
    count' "" joi ioi = (joi,ioi)
    count' ('J':'O':'I':cs) joi ioi = count' ('I':cs) (joi+1) ioi
    count' ('I':'O':'I':cs) joi ioi = count' ('I':cs) joi (ioi+1)
    count' (_:cs) joi ioi = count' cs joi ioi