import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    var n = 0
    val b = new ArrayBuffer[Int]
    while({n=readLine.trim.toInt;n}!=0) {
      var min = n
      for(i<-0 to 100) {
        for(j<-0 to Math.sqrt(n-i*i*i).toInt+1) {
          val m = j*j+i*i*i
          if(m>=0 && m<=n) {
            if(min > i+j+(n-m)) min = i+j+(n-m)
          }
        }
      }
      b += min
    }
    println(b.mkString("\n"))
  }
}