s = gets.chomp

ans = 0
while true
  f = false
  t = s.gsub("phnom", "penh")

  f |= s != t

  ans += s.size - t.size

  u = t.gsub("h", "").gsub("e", "h")

  f |= t != u

  break unless f
  ans += 1
  s = u.clone
end
puts ans