#include <stdio.h>
#include <string.h>
int main(void){
    
 char a[10002];
 for(;scanf("%s",a)+1;){
 
 
 int j=0,i=0,n=strlen(a),k;
 for(k=0;k<n;k++){
     if(a[k]=='O'){
         if(a[k-1]=='J'&&a[k+1]=='I')
         j++;
         
         if(a[k-1]=='I'&&a[k+1]=='I')
         i++;
     }
 }
 printf("%d\n%d\n",j,i);
 }
}