#include<iostream>
#include<string>
using namespace std;
int main(){
	string in;
	int joi,ioi;
	while(cin>>in){
	ioi=joi=0;
 	for(int i=0;i<in.size()-2;i++){
 		//cout<<in[i]<<in[i+1]<<in[i+2]<<endl;
 	
		if(in[i+0]=='I'&&in[i+1]=='O'&&in[i+2]=='I')ioi++;
		if(in[i+0]=='J'&&in[i+1]=='O'&&in[i+2]=='I')joi++;
			
	}
	cout<<joi<<endl<<ioi<<endl;
	}

}