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

int main(){
  string s;
  int a,b,c,d,e,f;
  while(cin >> s){
   a=0;b=0;c=0;d=0;e=0;f=0;
    while(a>=0||d>=0){
      a=s.find("JOI",b);
      d=s.find("IOI",e);
      if(a>=0){
          c++;
          b=a+1;
       }
      if(d>=0){
          f++;
          e=d+1;
      }
    }
    cout << c << endl << f << endl;
  }
  return 0;
}