#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void)
{
    char s[10000];
	int n,i,a,b;
	while(scanf("%s",s)!=EOF){
	    n=strlen(s);
		a=0; b=0;
		for(i=0;i<n-2;i++){
		    if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I'){
			    a++;
			}
			if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I'){
			    b++;
			}
		}
		printf("%d\n%d\n",a,b);
	}
	return 0;
}