import re s = input() ans = 0 c_op12 = 0 tr = str.maketrans('e', 'h', 'h') 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: c = [(len(m[0])- 3) // 2 for m in match] ans += sum(c) + max(c) ans += 1 # 最後の操作2の分 break elif 'h' in s or 'e' in s: s = s.translate(tr) ans += 1 else: break print(ans)