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

int main(void){
  int cntI, cntJ;
  string s;
  while(cin>>s){
    cntI = cntJ = 0;
    for (int i=0; i<=s.size()-3; i++){
      //cout << s.substr(i,3) << endl;
      if (s.substr(i, 3)=="JOI") cntJ++;
      if (s.substr(i, 3)=="IOI") cntI++;
    }
    cout << cntJ << endl << cntI << endl;
  }
  return 0;
}

