import sys def D(*a, **kwa): print(*a, file=sys.stderr, **kwa) pm = 'phnom' ph = 'penh' can_op1 = lambda s: pm in s can_op2 = lambda s: 'h' in s or 'e' in s tr = str.maketrans('e', 'h', 'h') op1 = lambda s: s.replace(pm, ph) op2 = lambda s: s.translate(tr) def solve(op, s, hist): if op == 1: if can_op1(s): s = op1(s) hist = hist + '1' return solve(2, s, hist) else: return hist else: if can_op2(s): s = op2(s) hist = hist + '2' h1 = solve(1, s, hist) h2 = solve(2, s, hist) return h1 if len(h1) > len(h2) else h2 else: return hist S = input() ans = 0 for i in range(1, 2+1): hist = solve(i, S, '') # D(hist) ans = max(ans, len(hist)) print(ans)