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

int main()
{
	string word;
	
	while(cin>>word)
	{
		int count,county;
		for(int i=0;(i=word.find("JOI",i))!=word.npos; i++)
		{
		    count++;
	        
		}
		cout<<count<<endl;
		count=0;
		for(int i=0;(i=word.find("IOI",i))!=word.npos; i++)
		{
			county++;
			
		}
		cout<<county<<endl;
		county=0;
	}
	return 0;
}