import scala.io.StdIn.{readInt,readLine}

object Main {

  def main(args:Array[String]) = {
    var n = 0
    while({n=readInt;n}!=0) {
      var min = n
      for(i<-0 to 100) {
        for(j<-0 to (n-i*i*i)) {
          val m = j*j+i*i*i
          if(m>=0 && m<=n) {
            if(min > i+j+(n-m)) min = i+j+(n-m)
          }
        }
      }
      println(min)
    }
  }
}