#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = read().rstrip().decode().replace('p', ' p') def solve(S): op1 = 0 op2 = 0 for _ in range(3): if S[:5] == 'phnom': S = S.replace('phnom', 'penh') op1 += 1 T = S.replace('h', '').replace('e', 'h') if S == T: return op1, op2 S = T op2 += 1 assert not S.count('e') if not S.startswith('phn'): if S.count('h'): return op1, op2 + 1 else: return op1, op2 # phn + om * k -> phn S = S[3:].replace('om', 'X') k = 0 for i, x in enumerate(S): if x == 'X': k += 1 else: break return op1 + k, op2 + k + 1 op1 = 0 op2 = 0 for x, y in map(solve, S.replace('p', ' p').split()): op1 += x if op2 < y: op2 = y print(op1 + op2)