s = input() l = [(s, 0)] r = 0 tt = s.maketrans({'h':None, 'e':'h'}) while l: nl = [] while l: s, i = l.pop(0) if i>=0: i = s.find('phnom', i) if i>=0: nl.append((s[:i]+'penh'+s[i+5:], i+4)) i += 5 l.append((s, i)) else: if 'h' in s or 'e' in s: nl.append((s.translate(tt), 0)) l = nl r += 1 print(r-1)