while 1:

    try:

        s=input()

        joi=0

        ioi=0

        for i in range(len(s)-2):

            if(s[i+1]=="O" and s[i+2]=="I"):

                if(s[i]=="J"):

                    joi+=1

                if(s[i]=="I"):

                    ioi+=1

        print(joi)

        print(ioi)

    except EOFError:

        break
import sys



for s in sys.stdin:

	joi=0

	ioi=0



	for i in range(0,len(s)-2):

		subs=s[i:i+3]

		if subs=="JOI":

			joi+=1

		elif subs=="IOI":

			ioi+=1



	print(joi)

	print(ioi)
while 1:
    try:
        s = input()
        joi = 0
        ioi = 0
        for i in range(len(s) - 2):
            if s[i + 1] == "O" and s[i + 2] == "I":
                if s[i] == "J":
                    joi += 1
                if s[i] == "I":
                    ioi += 1
        print(joi)
        print(ioi)
    except EOFError:
        break

import sys

for s in sys.stdin:
    joi = 0
    ioi = 0
    for i in range(0, len(s) - 2):
        subs = s[i : i + 3]
        if subs == "JOI":
            joi += 1
        elif subs == "IOI":
            ioi += 1
    print(joi)
    print(ioi)

-while 1: -    try: -        s = input() -        joi = 0 -        ioi = 0 -        for i in range(len(s) - 2): -            if s[i + 1] == "O" and s[i + 2] == "I": -                if s[i] == "J": -                    joi += 1 -                if s[i] == "I": -                    ioi += 1 -        print(joi) -        print(ioi) -    except EOFError: -        break +import sys + +for s in sys.stdin: +    joi = 0 +    ioi = 0 +    for i in range(0, len(s) - 2): +        subs = s[i : i + 3] +        if subs == "JOI": +            joi += 1 +        elif subs == "IOI": +            ioi += 1 +    print(joi) +    print(ioi)