Go: package main

import (
    "fmt"
    "math"
)

func main() {
    var e int
    for {
        fmt.Scan(&e)
        if e == 0 { break }

        var ans float64 = float64(e)
        for z := 0; z <= 101; z++ {
            for y := 0; y <= 1001; y++ {
                x := e - y*y - z*z*z
                if (0 <= x && x <= 100000) {
                  ans = math.Min(ans, float64(x+y+z));
                }
            }
        }
        fmt.Println(ans)
    }
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
// int a[1000010]={0};

int solve(int n){
	rep(i,1000010){
		if(i*i*i>n) break;
		rep(j,1000010){
			if(i*i*i+j*j>n) break;
			rep(k,1000010){
				if(i*i*i+j*j+k>n) break;
				if(n==i*i*i+j*j+k){
					cout<<i+j+k<<endl;
					return 0;
				}
			}
		}
	}
}
void mainmain(){
	vector<pii> a;
	vector<pii> b;
	rep(i,INF){
		if(i*i*i>1000000) break;
		a.PB(mkp(i*i*i,i));
	}
	rep(i,INF){
		if(i*i>1000000) break;
		b.PB(mkp(i*i,i));
	}
	int n;
	while(cin>>n,n){
		int ans=0;
		vector<pii>::iterator it1=upper_bound(ALL(a),mkp(n,INF));
		it1--;
		pii t1=*it1;
		cout<<t1.F<<" "<<t1.S<<endl;
		ans+=t1.S;
		n-=t1.F;
		vector<pii>::iterator it2=upper_bound(ALL(b),mkp(n,INF));
		pii t2=*it2;
		it2--;
		ans+=t2.S;
		n-=t2.F;
		cout<<ans+n<<endl;
	}
}
int a[1000010]={0};
void foo(){
	int c=1;
	bool f=false;
	while(1){
		f=false;
		rep(i,c){
			if(i*i*i>=1000010) break;
			rep(j,c-i){
				if(i*i*i+j*j>=1000010) break;
				rep(k,c-j){
					int t=i*i*i+j*j+k;
					if(t>=1000010){
						break;
					}
					else{
						f=true;
						a[t]=i+j+k;
					}
				}
			}
		}
		if(!f){
			break;
		}
		c++;		
	}
}
void mainmain2(){
	int n;
	// foo();
	while(cin>>n,n){
		int ans=INF;
		rep(z,n){
			if(z*z*z>n) break;
			int y=sqrt(n-z*z*z);
			ans=min(ans,z+y+(n-z*z*z-y*y));
		}
		cout<<ans<<endl;
	}

}



}
main() try{
    mainmain2();
}
catch(...){
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int E) {
    int m = INF;
    REP(y, 1000) REP(z, 100) {
        int x = E - (y * y) - pow(z, 3);
        if (x < 0) continue;
        m = min(m, x + y + z);
    }
    cout << m << endl;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
void solve(int n){
    int ans=INT_MAX;
    int j,tmp;
    for(int i=0;i*i*i<=n;i++){
        tmp=n-i*i*i;
        for(j=0;j*j<=tmp;j++){}
        j--;
        ans=min(ans,i+j+tmp-j*j);
    }
    cout<<ans<<endl;
}

int main(void){
    int n;
    while(cin>>n,n){
        solve(n);
    }
    
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int e;
	while (scanf("%d", &e), e)
	{
		int res = e;

		int z_max = pow(e, 1.0 / 3) + 1;
		int y_max = (int)sqrt(e + 0.0) + 1;
		for (int z = z_max; z; --z)
		{
			for (int y = y_max; y; --y)
			{
				int x = e - (z*z*z + y*y);
				if (x >= 0)
				{
					min_swap(res, x + y + z);
					break;
				}
			}
		}
		printf("%d\n", res);
	}
}

C++: #include <bits/stdc++.h>
#define inf 99999999
using namespace std;

int e,m;

int main(){
  int i,j,k,max;
  bool ch=0;
  while(1){
    cin >> e;
    if(e==0)break;
    m = inf;
    ch=0;
    max = sqrt(e);
    for(i=max;i>=0;i--)for(j=max;j>=0;j--)if(!ch){
	  int x = i*i*i+j*j;
	  if(x<=e){
	    if(i+j+e-x<m)m = i+j+e-x;
	  }
	}
    cout << m << endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

    while(1){
        int e;
        cin>> e;
        if(!e) break;

        int m=1e8;
        for(int y=0; y<=1000; y++){
            for(int z=0; z<=100; z++){
                int x=e-y*y-z*z*z;
                if(x<0) continue;
                m=min(m, x+y+z);
            }
        }

        cout<< m<< endl;

    }

    return 0;
}