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