s=list(input()) n=len(s) l=[] y=10**6 for i in range(n-3): if s[i]=="p" and s[i+1]=="a" and s[i+2]=="i" and s[i+3]=="n": y=i break if y==10**6: exit(print(-1)) ans=0 for i in range(y-3): if s[i]=="p" and s[i+1]=="o" and s[i+2]=="n": ans+=1 if ans<=1: print(-1) else: print(ans)