#include  <iostream>
#include  <algorithm>
#define INF 10000000
using namespace std;

int main(void){
	int e;
	while( cin >> e ,e){
		int m=INF;
		for(int y=0;y*y<=e;y++)
			for(int z=0;z*z*z<=e;z++){
				int x=e-y*y-z*z*z;
				if(x>=0)
					m=min(m,x+y+z);
			}
		cout << m << endl;
	}	
}