#include <stdio.h>

int main() {

  int x,y,z,z2,y2,x2;
  int m;
  int e,min;
  int i,j;

  while(1) {

    scanf("%d",&e);
    if(e == 0) break;
    x = 10000;
    min  = 1000000;

    for(j=0;j <=100;j++) {
      for(i=0;i<=1000;i++) {

	y2 = i * i;
	z2 = j * j * j;
	x2 = e - (j*j*j + i * i);


	if( x2 + i + j < min && x2 >= 0) {
	  z = j;
	  y  = i;
	  min = i + j + x2;
	  x = x2;
	  //  printf("z = %d\ny = %d\nx = %d\nmin = %d\n",z,y,x,min);
	}
      }
    }


    printf("%d\n",min);

  }

  return 0;

}