while true
    e=gets.to_i
    if e==0
        break
    end
    ret=e
    for z in 0...(e**1/3)+1
        ee=e-z**3
        if ee<0
            next
        end
        y=(ee**0.5).to_i
        x=ee-y**2
        ret=[ret,x+y+z].min
    end
    puts ret
end