#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		ll ans=1e9;
		rep(z,0,ans){
			if(z*z*z>n)break;
			rep(y,0,ans-z){
				if(z*z*z+y*y>n)break;
				ans=min(ans,z+y+n-z*z*z-y*y);
			}
		}
		printf("%lld\n",ans);
	}
}
