import re import sys S = input() if S not in "pain": 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)