#encoding:utf-8 No.0522 2014.12.11
while str = gets.chomp.split("")
  cnt_joi = 0
  cnt_ioi = 0
  i = 0

  while i < str.length
    if str[i] == "J" && str[i+1] == "O" && str[i+2] == "I"
      cnt_joi += 1
    end

    if str[i] == "I" && str[i+1] == "O" && str[i+2] == "I"
      cnt_ioi += 1
    end

    i += 1
  end

  puts cnt_joi
  puts cnt_ioi
end