p=input() n=p.find(pain) if n==1: print(-1) elif p.count(pon,0,n)<2: print(-1) else: print(p.count(pon,0,n)-1)