# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read #n,*a = [int(i) for i in read().split()] #a = [int(i) for i in readline().split()] #n = int(input()) s = input() ans = 0 c = s.count("phnom") if c==0: if "h" in s or "e" in s: ans = 1 s = s.replace("h","").replace("e","h") c = s.count("phnom") if c==0: if "h" in s or "e" in s: print(ans+1) exit() else: print(ans) exit() else: print(0) exit() s = s.replace("phnom","penh").replace("h","").replace("e","h") ans += c+1 c = s.count("phnom") if c==0: if "h" in s or "e" in s: ans = 1 s = s.replace("h","").replace("e","h") c = s.count("phnom") if c==0: if "h" in s or "e" in s: print(ans+1) exit() else: print(ans) exit() else: print(0) exit() s = s.replace("phn","X").replace("om","Y") def getans(s,ans): q = [] res = 0 depth = 0 for i in s[::-1]: if not q: q.append(i) else: if i=="X": r = 0 while q and q[-1]=="Y": q.pop() r += 1 res += r depth = max(depth,r) q.append(i) if res==0: print(ans+1) exit() else: print(ans+res+depth+1) getans(s,ans)