# AOJ 0522: JOI and IOI

# Python3 2018.6.30 bal4u



import re



match = re.findall(r'[0-9]+', 'xxxx1aaaa22cc333ssss')

while True:

	try: s = input()

	except: break

	joi = 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, ioi, sep='\n')

# AOJ 0522: JOI and IOI

# Python3 2018.6.30 bal4u



while True:

	try: s = input()

	except: break

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

	print(*[c.count(a) for a in ["JOI", "IOI"]], sep='\n')

# AOJ 0522: JOI and IOI
# Python3 2018.6.30 bal4u
import re

match = re.findall(r"[0-9]+", "xxxx1aaaa22cc333ssss")
while True:
    try:
        s = input()
    except:
        break
    joi = 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, ioi, sep="\n")

# AOJ 0522: JOI and IOI
# Python3 2018.6.30 bal4u
while True:
    try:
        s = input()
    except:
        break
    c = [s[i : i + 3] for i in range(len(s) - 2)]
    print(*[c.count(a) for a in ["JOI", "IOI"]], sep="\n")

-import re - -match = re.findall(r"[0-9]+", "xxxx1aaaa22cc333ssss") -    joi = 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, ioi, sep="\n") +    c = [s[i : i + 3] for i in range(len(s) - 2)] +    print(*[c.count(a) for a in ["JOI", "IOI"]], sep="\n")