loop do
    e = gets.to_i
    break if e == 0
    z, ans = 0, e

    while z**3 <= e:
        y = int(Math.sqrt((e-z**3)))
        x = e - y**2 - z**3
        ans = [ans, x + y + z].min
        z += 1
    end
    puts ans
end
