import java.lang.Math.cbrt
import java.lang.Math.sqrt
fun cbrt(value:Int):Int {
    return cbrt(value.toDouble()).toInt()
}
fun sqrt(value:Int):Int {
    return sqrt(value.toDouble()).toInt()
}
fun main(args:Array<String>):Unit{
    while (true){
        val e = readLine()!!.toInt()
        if (e == 0) return
        var minM = Int.MAX_VALUE
        for (z in 0 .. cbrt(e)){
            val y = sqrt(e - z * z * z)
            val m = z + y + (e - z * z * z - y * y)
            if (minM > m)
                minM = m
        }
        println(minM)
    }
}
