#include <iostream>
#include <string>

using namespace std;

int main() {
	string a;
	while (cin >> a) {
		int counter = 0;
		int counter2 = 0;
		int i = 0;
		while (a.find("JOI", i) != string::npos) {
			counter++;
			i = a.find("JOI", i)+1;
		}
		i = 0;
		while (a.find("IOI", i) != string::npos) {
			counter2++;
			i = a.find("IOI", i)+1;
		}
		cout << counter << endl << counter2 << endl;
	}
	return 0;
}