loop do
    e = gets.to_i
    break if e == 0
    m = e
    for z in 0..100
        break if z**3 > e
        lim = Math.sqrt((e-z**3)).floor
        for y in 0..lim
            x = e-z**3-y**2
            m = x + y + z if x + y + z < m
        end
    end
    puts m
end