#include <iostream>
#include <string>

using namespace std;

int main() {

	string s;
	int joi, ioi;

	while(cin >> s) {
		joi=ioi=0;
		for(int i=0; i<s.size()-2; i++) {
			if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I') {
				joi++;
			}
			if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I') {
				ioi++;
			}
		}
		cout << joi << endl << ioi << endl;
	}
			
	return 0;

}