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

void solve(string s) {
	int i, joi = 0, ioi = 0;
	for (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;
	cout << ioi << endl;
}

int main() {
	string s;
	while (cin >> s) {
		solve(s);
	}
	return 0;
}