S = input() if "pain" not in S: print(-1) exit() S = S.split("pain")[0] print(S.count("pon") - 1)