import re

string = raw_input()
mutch = re.findall("J*O*I*", string)

max = 0
for s in mutch:
	if s.count("O") == min([s.count(c) for c in ("J", "O", "I")]):
		k = s.count("O")
		
	if k > max:
		max = k

print max