def main(): import sys input = sys.stdin.readline S = [s for s in input().rstrip('\n')] phnom = 'phnom' penh = 'penh' penhx = 'penh!' ans = 0 for i in range(len(S) - 4): flg = 1 for j in range(5): if S[i+j] != phnom[j]: flg = 0 if flg: ans += 1 for j in range(5): S[i+j] = penhx[j] if 'h' not in S and 'e' not in S: print(ans) assert 0 exit() S_new = [] ans += 1 for s in S: if s == '!' or s == 'h': continue if s == 'e': S_new.append('h') else: S_new.append(s) S_new.append('!') flg = 0 has_phnom = 0 #print(ans) #print(S_new) n = len(S_new) i = 0 om_num_max = 0 while i < n: #print(flg, i) if flg == 0: if i+2 < n: ok = 1 for j in range(3): if S_new[i+j] != phnom[j]: ok = 0 else: ok = 0 if ok: has_phnom = 1 flg = 1 i += 3 om_num = 0 else: i += 1 elif flg == 1: if S_new[i] == 'o': flg = 2 i += 1 else: om_num_max = max(om_num_max, om_num) ans += om_num flg = 0 elif flg == 2: if S_new[i] == 'm': om_num += 1 flg = 1 i += 1 else: om_num_max = max(om_num_max, om_num) ans += om_num flg = 0 if not has_phnom: if 'e' in S_new: ans += 2 elif 'h' in S_new: ans += 1 else: ans += 1 ans += om_num_max print(ans) if __name__ == '__main__': main()