#include <iostream>

using namespace std;

int main(){
  string str;
  while(cin>>str && str!="EOF"){
    int cntA=0,cntB=0;
    for(int i=0;i<str.size()-2;i++){
      if(str[i]=='J' && str[i+1]=='O' && str[i+2]=='I'){cntA++;}
      if(str[i]=='I' && str[i+1]=='O' && str[i+2]=='I'){cntB++;}
    }
    cout<<cntA<<endl;
    cout<<cntB<<endl;
  }
}
