import re import sys S = input() if "pain" not in S: print(-1) sys.exit() S = S.split("pain") # print(S) results = re.findall(r"pon", S[0]) if results: print(len(results)-1) else: print(-1)