#include <stdio.h>

int main() {

  int x,y,z;
  int m;
  int e,min;
  int i,j;

  while(1) {

    scanf("%d",&e);
    if(e == 0) break;

    min  = 1000000;

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

	x = e - (j*j*j + i * i);

	if(x >= 0 && x < min ) {
	  z = j;
	  y  = i;
	  min = x;
	}
      }
    }

    printf("%d\n",z+y+z);

  }

  return 0;

}