#include <stdio.h>

// x + y*y + z*z*z = eð½·Æ«Ìx+y+zÌÅ¬Ìlðßé

int main(){
	int e,x,y,z,answer;

	while(1){
		answer=1000000;
		scanf("%d", &e);
		if(e==0)break;

		for(y=0 ; y<1000 ; y++){//(y*y)<1000000 <=> y<1000
			for(z=0 ; z<100 ; z++){//(z*z*z)<1000000 <=> z<100
				x = e - (y*y) - (z*z*z);
				if(x<0)continue;
				if(answer>x+y+z)answer = x+y+z;
			}
		}
		printf("%d\n", answer);//¦ÌoÍ
	}
	return 0;
}