def itami(s: str) -> int: if "pain" not in s: return -1 cnt = s.split("pain")[0].count("pon") if cnt>=2: return cnt-1 else:return -1 S=input() print(itami(S))