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

int main( void ) {
	int i, e, ee, cbrte, sqrtee, x, y, z, min;

	while ( scanf( "%d", &e ), e ) {
		min = e;

		cbrte = pow( e, 1.0 / 3 ) + 0.0000000001;
		for ( z = 0; z <= cbrte; z++ ) {
			ee = e - z * z * z;
			sqrtee = sqrt( ee );
			for ( y = 0; y <= sqrtee; y++ ) {
				x = ee - y * y;

				if ( x + y + z < min )
					min = x + y + z;
			}
		}

		printf( "%d\n", min );
	}

	return 0;
}