def max_operations(S): current = S count = 0 while True: # Apply all possible operation 1 new_str = current while True: index = new_str.find('phnom') if index == -1: break new_str = new_str[:index] + 'penh' + new_str[index+5:] count += 1 if new_str == current: # No change in operation 1, try operation 2 # Apply operation 2 temp = new_str.replace('h', '') temp = temp.replace('e', 'h') if temp != new_str: count += 1 new_str = temp else: # No change in operation 2, break break current = new_str return count # Read input S = input().strip() # Compute result result = max_operations(S) # Output the result print(result)