#include <stdio.h>
#include <stdlib.h>

int main(void){
  int e,m,min,x,y,z;
  while(1){
    scanf("%d", &e);
    if(e==0)break;
    min = 10000000;
    for(y=0;y<1000;y++){
      for(z=0;z<100;z++){
	x = e-(y*y+z*z*z);
	if(x<0)continue;
	m = x+y+z;
	if(min > m){
	  min = m;
	}
      }
    }
    printf("%d\n", min);
  }
  return 0;
}