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

int main(void){
	string a;	
	while(cin >> a){
		if(cin.eof())
			break;
		int ans[2]={0};
		for(int i=0;i<a.size()-2;i++){
			if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I')
				ans[0]++;
			if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I')
				ans[1]++;
		}
		cout << ans[0] << endl;
		cout << ans[1] << endl;
	}
	return 0;
}