#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n,joi=0,ioi=0;
  char s[10010];
  while(cin >> s){
    joi=0;
    ioi=0;
    n=strlen(s);
    for(int i=0;i<n;i++){
      if(s[i]=='J')if(s[i+1]=='O')if(s[i+2]=='I'){
	    joi++;
	  }
      if(s[i]=='I')if(s[i+1]=='O')if(s[i+2]=='I'){
	    ioi++;
	  }
    }
    cout << joi << endl << ioi << endl;
  }
}