S=input() LEN=len(S) S+="z"*100 D1=[] D2=[] for i in range(LEN): if S[i:i+3]=="phn": ind=i+3 count=0 while True: if S[ind]=="h" or S[ind]=="e": ind+=1 elif count%2==0 and S[ind]=="o": ind+=1 count+=1 elif count%2==1 and S[ind]=="m": ind+=1 count+=1 else: break #print(i,ind) D1.append(count//2) for i in range(LEN): if S[i:i+2]=="om": ind=i-1 while ind>=0 and S[ind]=="h": ind-=1 #print(i,ind) if S[ind-2:ind+1]=="pen": ind2=i count=0 while True: if S[ind2]=="h" or S[ind2]=="e": ind2+=1 elif count%2==0 and S[ind2]=="o": ind2+=1 count+=1 elif count%2==1 and S[ind2]=="m": ind2+=1 count+=1 else: break D2.append(count//2) if D1==[] and D2==[]: if "e" in S: print(2) elif "h" in S: print(1) else: print(0) else: if D2==[]: print(sum(D1)+max(D1)+1) elif D1==[]: print(sum(D2)+max(D2)+2) else: if max(D1)>max(D2): print(sum(D1)+sum(D2)+max(D1)+1) else: print(sum(D1)+sum(D2)+max(D2)+2)