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

int main(){
	string str;
	while (cin >> str){
		int joi = 0, ioi = 0;
		for (int i = 0; i < str.size() - 2; i++){
			if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') joi++;
			if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I') ioi++;
		}
		cout << joi << endl;
		cout << ioi << endl;
	}
	return 0;
}