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

int main(){
  string s;
  int n,m;
  while(cin>>s){
    n=m=0;
    int i=s.find("JOI");
    while(i!=string::npos){
      i=s.find("JOI",i+1);
      ++n;
    }
    i=s.find("IOI");
    while(i!=string::npos){
      i=s.find("IOI",i+1);
      ++m;
    }
    cout<<n<<'\n'<<m<<endl;
  }
  return 0;
}