S=input() LEN=len(S) S+="z"*100 LEN=len(S) MAX=0 for i in range(LEN): if S[i:i+3]=="phn": s=0 j=i+3 while S[j:j+2]=="om": s+=1 j+=2 MAX=max(s,MAX) if MAX==0: ANS=0 else: ANS=MAX*2+1 T="" for s in S: if s=="h": continue if s=="e": T+="h" else: T+=s if S==T: print(ANS) else: MAX=0 for i in range(len(T)): if T[i:i+3]=="phn": s=0 j=i+3 while T[j:j+2]=="om": s+=1 j+=2 MAX=max(s,MAX) if MAX==0: print(max(ANS,1)) else: print(max(ANS,MAX*2+2))