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

int main(void)
{
	int i,j;
	int y,z;
	int e,m,tmp;
	double es;
	
	while(1)
	{
		scanf("%d ",&e);
		if(e==0)break;
		
		m=e;
		es = sqrt(e);
		
		for(y=0;y<=es;y++){
			i = y*y;
			for(z=0;z<e;z++){
				if(z*z*z > e-i){
					z--;
					tmp = e -i -z*z*z +y +z;
					if(m>tmp)m=tmp;
					break;
				}
			}
		}	
		
		printf("%d\n",m);
	}
	return 0;
}
	