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