#encoding:utf-8
loop do
	# puts "??°?????\?????????????????????"
  energy = gets.to_i
  break if energy==0
  ans = 1000000000000000000 #??¨??????????????§??????????????°????¨???\

  for y in 0..energy**(1/2.0)
      for z in 0..energy**(1/3.0)
          x = energy -y**2 -z**3
          if ans > (x+y+z) && x>=0
            ans = x+y+z
          end
        end
      end
  p ans
end