(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"), str, joi, ioi;
    while(true) {
        joi = 0;
        ioi = 0;
        str = inputs.shift();
        if(str === '') {
            break;
        }
        for(var i = 0, len = str.length; i < len - 2; i++) {
            var tmp = str[i] + str[i + 1] + str[i + 2];
            if(tmp == 'JOI') {
                joi++;
            }
            if(tmp == 'IOI') {
                ioi++;
            }
        }
        console.log(joi + "\n" + ioi);
    }
})(require("fs").readFileSync("/dev/stdin", "utf8"));