import re import sys # sys.stdin = open('c.txt') s = input() ans = 0 tr = str.maketrans('e', 'h', 'h') c_op12 = 0 while True: n = s.count('phnom') if n > 0: s = s.replace('phnom', 'penh').translate(tr) ans += n + 1 c_op12 += 1 if c_op12 == 2: match = re.findall('(phn(om)+)', s) if match: max_c = 0 for m in match: c = (len(m[0])-3)//2 ans += c max_c = max(max_c, c) ans += max_c ans += 1 # 最後の操作2の分 break else: if 'h' in s or 'e' in s: s = s.translate(tr) ans += 1 else: break print(ans)