while 1:

	try:

		a=input()

		cjoi=cioi=0

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

			if a[i:i+3]=="JOI":

				cjoi+=1

			if a[i:i+3]=="IOI":

				cioi+=1

		print(cjoi)

		print(cioi)

	except:

		break		
while 1:

	try:

		a=input()

		cjoi=cioi=0

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

			if   a[i]=="J" and a[i+1]=="O" and a[i+2]=="I":cjoi+=1

			elif a[i]=="I" and a[i+1]=="O" and a[i+2]=="I":cioi+=1

		print(cjoi)

		print(cioi)

	except:

		break		
while 1:
    try:
        a = input()
        cjoi = cioi = 0
        for i in range(len(a) - 2):
            if a[i : i + 3] == "JOI":
                cjoi += 1
            if a[i : i + 3] == "IOI":
                cioi += 1
        print(cjoi)
        print(cioi)
    except:
        break

while 1:
    try:
        a = input()
        cjoi = cioi = 0
        for i in range(len(a) - 2):
            if a[i] == "J" and a[i + 1] == "O" and a[i + 2] == "I":
                cjoi += 1
            elif a[i] == "I" and a[i + 1] == "O" and a[i + 2] == "I":
                cioi += 1
        print(cjoi)
        print(cioi)
    except:
        break

-            if a[i : i + 3] == "JOI": +            if a[i] == "J" and a[i + 1] == "O" and a[i + 2] == "I": -            if a[i : i + 3] == "IOI": +            elif a[i] == "I" and a[i + 1] == "O" and a[i + 2] == "I":