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