while s = gets
  s = s.chomp
  cnt_j = 0
  cnt_i = 0
  for i in 0..(s.length-2)
    t = s[i,3]
    if t == 'JOI'
       cnt_j += 1 
   end
   if t == 'IOI'
    cnt_i += 1 
  end
  end
  puts cnt_j
  puts cnt_i    
end

