import sys

for e in sys.stdin:

 s=sum((e[i:i+3]=='JOI')+1j*(e[i:i+3]=='IOI')for i in range(len(e)-3))

 print((int(s.real)))

 print((int(s.imag)))

import sys

for e in sys.stdin:

 s=[e[i:i+3]for i in range(len(e)-3)]

 for w in['JOI','IOI']:print((s.count(w)))

import sys

for e in sys.stdin:
    s = sum(
        (e[i : i + 3] == "JOI") + 1j * (e[i : i + 3] == "IOI")
        for i in range(len(e) - 3)
    )
    print((int(s.real)))
    print((int(s.imag)))

import sys

for e in sys.stdin:
    s = [e[i : i + 3] for i in range(len(e) - 3)]
    for w in ["JOI", "IOI"]:
        print((s.count(w)))

-    s = sum( -        (e[i : i + 3] == "JOI") + 1j * (e[i : i + 3] == "IOI") -        for i in range(len(e) - 3) -    ) -    print((int(s.real))) -    print((int(s.imag))) +    s = [e[i : i + 3] for i in range(len(e) - 3)] +    for w in ["JOI", "IOI"]: +        print((s.count(w)))