#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	return 0;

}

