import std.stdio;
import std.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;

void main() {
    foreach (string line; stdin.lines) {
        string s = line.chomp;
        int joi = 0;
        int ioi = 0;
        for (int i = 0; i < s.length - 2; i++) {
            if (s[i..i+3] == "JOI") {
                joi++;
            } else if (s[i..i+3] == "IOI") {
                ioi++;
            }
        }
        joi.writeln;
        ioi.writeln;
    }
}