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