#include<cstdio>
#include<cstring>
using namespace std;
int main(void){
   char c[10001];
   while(scanf("%s",c) != EOF){
      int i_cnt = 0,j_cnt = 0;
      for(int i = 0;i < strlen(c)-2;i++){
         if(c[i] == 'I' && c[i+1] == 'O' && c[i+2] == 'I') i_cnt++;
         if(c[i] == 'J' && c[i+1] == 'O' && c[i+2] == 'I') j_cnt++;
      }
      printf("%d\n%d\n",j_cnt,i_cnt);
   }
   return 0;
}