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