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

int main()
{
	while(true){
		string line;
		cin>>line;
		if(!line.size()){break;}
		int joi = 0, ioi = 0;
		
		for(int i = 0; i < line.size() - 2; i++){
			if(line[i + 1] == 'O' && line[i + 2] == 'I'){
				if(line[i] == 'J'){
					joi++;
				}
				else if(line[i] == 'I'){
					ioi++;
				}
			}
		}
		cout<<joi<<endl<<ioi<<endl;
	}
	return 0;
}