#!/usr/bin/env python

# -*- coding: utf-8 -*-



while True:

    try:

        s = eval(input(''))

    except:

        break



    n_joi = 0

    n_ioi = 0

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

        cut_s = s[i:i+3]

        if cut_s == 'JOI':

            n_joi += 1

        if cut_s == 'IOI':

            n_ioi += 1



    print(n_joi)

    print(n_ioi)
#!/usr/bin/env python

# -*- coding: utf-8 -*-



while True:

    try:

        input_s = eval(input())

    except:

        break



    s_list = [input_s[i:i+3] for i in range(len(input_s[:-2]))]



    n_joi = 0

    n_ioi = 0

    for s in s_list:

        if s == 'JOI':

            n_joi += 1

        if s == 'IOI':

            n_ioi += 1



    print(n_joi)

    print(n_ioi)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
    try:
        s = eval(input(""))
    except:
        break
    n_joi = 0
    n_ioi = 0
    for i in range(len(s[:-2])):
        cut_s = s[i : i + 3]
        if cut_s == "JOI":
            n_joi += 1
        if cut_s == "IOI":
            n_ioi += 1
    print(n_joi)
    print(n_ioi)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
    try:
        input_s = eval(input())
    except:
        break
    s_list = [input_s[i : i + 3] for i in range(len(input_s[:-2]))]
    n_joi = 0
    n_ioi = 0
    for s in s_list:
        if s == "JOI":
            n_joi += 1
        if s == "IOI":
            n_ioi += 1
    print(n_joi)
    print(n_ioi)

-        s = eval(input("")) +        input_s = eval(input()) +    s_list = [input_s[i : i + 3] for i in range(len(input_s[:-2]))] -    for i in range(len(s[:-2])): -        cut_s = s[i : i + 3] -        if cut_s == "JOI": +    for s in s_list: +        if s == "JOI": -        if cut_s == "IOI": +        if s == "IOI":