#include<stdio.h>



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

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