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

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