while line = STDIN.gets
	
	ioi = 0;
	joi = 0;
	c = 0;

	while c = line.index("JOI", c)
		if(c.nil?)
			break
		else
			joi+=1
			c+=2
		end
	end	
	
	c = 0;
	
	while c = line.index("IOI", c)
		if(c.nil?)
			break
		else
			ioi+=1
			c+=2
		end
	end
		
	p joi
	p ioi
end