while line = gets
    line = line.chomp
    joi = ioi = 0
    for i in 0..(line.length-3)
        joi += 1 if line[i, 3] == "JOI"
        ioi += 1 if line[i, 3] == "IOI"
    end
    puts joi
    puts ioi
end
