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=[] for s in S: queue.append(s) if len(queue)>=5 and queue[-5:]==list("phnom"): for _ in range(2): queue.pop() ans+=2 if "h" in queue: ans+=1 print(ans)