str=gets.chomp
n=str.length
i=0
count=0
count2=0
while i<n
  if str[i]=='J' && str[i+1]=='O' && str[i+2]=='I'
    count=count+1
  elsif str[i]=='I' && str[i+1]=='O' && str[i+2]=='I'
    count2=count2+1
  end
  i=i+1
end

p count
p count2