#include <stdio.h>

int tansaku_2(int target) {
	int left,right,mid;
	unsigned long long mid2;
	if(target<4)return 0;
	left=2;right=target;
	while(left<=right) {
		mid=(left+right)/2;
		mid2=(unsigned long long)mid*mid;
		if(mid2==(unsigned long long)target)return mid;
		else if(mid2<(unsigned long long)target)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}
/*
int tansaku_3(int target) {
	int left,right,mid;
	unsigned long long mid3;
	if(target<8)return 0;
	left=2;right=target;
	while(left<=right) {
		mid=(left+right)/2;
		mid3=(unsigned long long)mid*mid*mid;
		if(mid3==(unsigned long long)target)return mid;
		else if(mid3<(unsigned long long)target)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}
*/
int main(void) {
	int e,e2;
	int x,y,z;
	int min;
	while(1) {
		scanf("%d",&e);
		if(e==0)break;
		min=0x7fffffff;
		for(z=0;z*z*z<=e;z++) {
			e2=e-z*z*z;
			y=tansaku_2(e2);
			x=e2-y*y;
			if(x+y+z<min)min=x+y+z;
		}
		printf("%d\n",min);
	}
	return 0;
}