#!/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() op1 = S.count('phnom') S = S.replace('phnom', 'penh') T = S.replace('h', '').replace('e', 'h') if S == T: print(op1) exit() S = T def solve(S): assert not S.count('e') if not S.startswith('phn'): if S.count('h'): return 0, 1 else: return 0, 0 # 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 k, k + 1 op2 = 1 for x, y in map(solve, S.replace('p', ' p').split()): op1 += x if op2 < 1 + y: op2 = 1 + y print(op1 + op2)