c=f=0 for i in input().replace("np","n p").split(): if i=="pain": f=1 break elif i=="pon":c+=1 print(c-1if f else -1)