J = "JOI"
I = "IOI"

while s = gets
  cnt_j = 0
  cnt_i = 0
  for i in 0..(s.length-3) do
    if s[i] == J[0]
      cnt_j += 1 if s[i+1] == J[1] && s[i+2] == J[2]
    end
    if s[i] == I[0]
      cnt_i += 1 if s[i+1] == I[1] && s[i+2] == I[2]
    end
  end
  puts cnt_j
  puts cnt_i
end