#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  while (true) {
    int joi = 0;
    int ioi = 0;
    cin >> s;
    if (cin.eof()) {
      return 0;
    }
    for (size_t i = 0; i < s.length(); ++i) {
      if (s.substr(i, 3) == "JOI") {
        ++joi;
      } else if (s.substr(i, 3) == "IOI") {
        ++ioi;
      }
    }
    cout << joi << endl << ioi << endl;
  }
}