#include <bits/stdc++.h>
using namespace std;

int main() {
  while (true) {
    string s;
    cin >> s;
    int a = 0, b = 0;
    if (s == "") break;
    for (int i = 0; i < s.size() - 2; i++) {
      if (s.at(i) == 'J' && s.at(i + 1) == 'O' && s.at(i + 2) == 'I') a++;
      if (s.at(i) == 'I' && s.at(i + 1) == 'O' && s.at(i + 2) == 'I') b++;
    }
    cout << a << endl;
    cout << b << endl;
  }
}
