### main

str = gets.strip
len = str.length

n = 0
k = 0

while k < len
  k0 = str.index('O', k)
  break if k0.nil?

  k1 = k0 + 1
  while str[k1] == 'O'
    k1 += 1
  end

  n0 = k1 - k0

  if k0 >= n0 && (str[k0 - n0, n0] == 'J' * n0) && (str[k1, n0] == 'I' * n0)
    n = n0 if n < n0
    k = k1 + n0
  else
    k = k1
  end
end

puts n