S=list(input()) def operate(S,T0,T1): queue=[] cnt=0 for s in S: queue.append(s) while len(queue)>=len(T0) and queue[len(queue)-len(T0):]==T0: for _ in range(len(T0)): queue.pop() for t in T1: queue.append(t) cnt+=1 return queue,cnt ans=0 S,cnt=operate(S,list("phnom"),list("penh")) ans+=cnt if "h" in S or "e" in S: S,_=operate(S,["h"],[]) S,_=operate(S,["e"],["h"]) ans+=1 queue=[] cnt=[] for s in S: queue.append(s) if len(queue)>=5 and queue[-5:]==list("phnom"): cnt.append(1) elif len(queue)>=7 and queue[-7:]==list("phnomom"): for _ in range(2): queue.pop() cnt[-1]+=1 if cnt: ans+=sum(cnt)+max(cnt)+1 elif "h" in S: ans+=1 print(ans)