#include<iostream>
#include<string>
using namespace std;

int main() {
	string joi;
	while (cin >> joi) {
		int cjo=0,cio=0;
		int z = joi.size();
		for (int i = 0; i < z - 2; i++) {
			string sb = joi.substr(i, 3);
			if (sb == "JOI") { cjo++; }
			if (sb == "IOI") { cio++; }
		}
		cout << cjo << endl << cio << endl;
	}
	return 0;
}