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