S = list(input()) N = len(S) ans = 0 flag = 1 phn = 0 oflag = 0 for i in range(2,N): if S[i-2] == 'p' and S[i-1] == 'h' and S[i] == 'n': phn = 1 elif S[i] == 'o' and phn: oflag = 1 elif S[i] == 'm' and oflag and phn: if flag: ans += 1 flag = 0 ans += 2 oflag = 0 else: oflag = 0 phn = 0 penh = 0 oflag = 0 for i in range(3,N): if S[i-3] == 'p' and S[i-2] == 'e' and S[i-1] == 'n' and S[i] == 'h': penh = 1 elif S[i] == 'o' and penh: oflag = 1 elif S[i] == 'm' and oflag and penh: if flag: ans += 2 flag = 0 ans += 2 oflag = 0 else: oflag = 0 penh = 0 print(ans)