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