#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main(){
	string str;
	string  JOI="JOI",IOI="IOI";
	while(cin>>str){
		int answer1=0;
		int answer2=0;
		for(int i=0;i<str.size()-2;++i){
			if(str.substr(i,3)==JOI)++answer1;
			if(str.substr(i,3)==IOI)++answer2;
		}
		cout<<answer1<<endl<<answer2<<endl;
	}
	return 0;
}