#include<iostream>
#include<string>
using namespace std;
int main(){
  string d;
  while(cin>>d){
    int joi=0,ioi=0,n=0,m=0;
    while(1){
      if(d.find("JOI",n)==-1) break;
      n = d.find("JOI",n);
      joi++;
      n+=2;
    }
    while(1){
      if(d.find("IOI",m)==-1) break;
      m = d.find("IOI",m);
      ioi++;
      m+=2;
    }
     cout << joi << endl << ioi << endl;
  }
  return 0;
}