S=input() LEN=len(S) S+="z"*100 LEN=len(S) L=[] 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 L.append(s) if L==[]: ANS=0 else: ANS=max(L)+sum(L)+1 T="" for s in S: if s=="h": continue if s=="e": T+="h" else: T+=s if S==T: print(ANS) else: L=[] 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 L.append(s) if L==[]: if "h" in T: ANS2=2 else: ANS2=1 else: ANS2=max(L)+sum(L)+2 print(max(ANS,ANS2))