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