def main(): S = input() target = 'pain' idx = S.find(target) if idx == -1: print(idx) else: r = S[:idx] pains = r.count('pon') - 1 print(pains) if __name__ == '__main__': main()