while 1:print(raw_input()*2).rfind("LOS")+1or"PHONY"