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 <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

#define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化

    int e;



    while(cin>>e){

        int ans=INF;

        if(e==0)break;

        REP(i,100){
            REP(j,1000){
                REP(k,1000000){

                    if(i>e||j>e||k>e||(k+j*j+i*i*i)>e)break;
                    // cout<<i<<" "<<j<<" "<<k<<endl;

                    if(k+j*j+i*i*i==e){
                        ans=min(i+j+k,ans);
                    }
                }
            }
        }

        cout<<ans<<endl;


    }
    
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;




int main(){
    int e;
    while(cin>>e){
        if(e==0)break;
        
        int mi=INF;
        rep(i,1001){
            rep(j,101){
                int a=(e-(i*i + j*j*j) );
//                cout<<i<<" "<<j<<" "<<a<<endl;
                if(a<0)break;
                mi=min(mi,a+i+j);

            }
        }
        cout<<mi<<endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;


/*
???????§?????§????????????±???3??´
????°???°??????

??????????¨????????????????0??????????§??????????????????§
?????????????????£???????????????????????£????????????????°???\?????¨accepted??§?????????

*/


int e;

/*
int main(){

  while(true){
    int min, ylim, zlim;
    cin >> e;
    min = e;

    ylim = pow(e,1.0/2.0);
    zlim = pow(e,1.0/3.0);
    
    if(e == 0)break;
    for (int z = 0; z <= zlim; ++z){
       for (int y = 0; y <= ylim; ++y){
	  for (int x = 0; x <= e; ++x){
	    if((x + y*y + z*z*z) == e){
	      if((x + y + z) <= min){
		min = x + y + z;
		//cout << "xyz = " << x << " " << y << " " << z << " min = " << min << endl;
		break;
	      }
	    }
	  }
       }
    }
    cout << min << endl;
    
  }
}
*/


int main(){

  while(true){
    int min, ylim, zlim;
    cin >> e;
    min = e;

    ylim = pow(e,1.0/2.0) + 1;
    zlim = pow(e,1.0/3.0) + 1;
    
    if(e == 0)break;
    for (int z = 0; z <= zlim; ++z){
      for (int y = 0; y <= ylim; ++y){
	int x = e - z*z*z - y*y;
	if((x + y + z) <= min && x >= 0){
	  min = x + y + z;
	  //cout << "xyz = " << x << " " << y << " " << z << " min = " << min << endl;
	}
      }
    }
    cout << min << endl;
    
  }
}

C++: #include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define mp(a,b) make_pair(a,b)
using namespace std;


int main(){
	int e;
	while(cin>>e,e){
		int mini=1000000;
		for(int x=0;x<=e;x++){
			for(int y=0;x+y*y<=e;y++){
				for(int z=0;x+y*y+z*z*z<=e;z++){
					if(x+y*y+z*z*z==e)
						mini=min(mini,x+y+z);
				}
			}
		}
		p(mini);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
#include<math.h>

#define MAX 1000000
int min(int a, int b);

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}
int main()
{
    while (1)
    {
        int y, z, e, ans = MAX;
        cin >> e;
        if (!e)
            break;
        for (z=0; z*z*z <= e; z++) {
            y = (int)sqrt((double)e - z*z*z);
            ans = min(ans, e - y*y - z*z*z + y + z);
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
/*
int pow(int a,int b){
    int R=1;
    while(b){
        if(b&1) R=(R*a);
        a=(a*a);
        b>>=1;
    }
    return R;
}
*/
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int e;
	while(cin >> e , e){
		int m=1e+9;
		/*
		for(int z=0 , z1=0 ; z<=e; ++z1 , z=z1*z1*z1){
			for(int y=0 , y1=0 ; y<=e; ++y1 , y=y1*y1){
				int x=e-y-z;
				if(x>=0) m = min(m , x+(int)sqrt(y)+(int)cbrt(z));
			}
		}
		*/
		for(int z=0 ; z*z*z<=e ; ++z){
			for(int y=0 ; y*y<=e ; ++y){
				int x=e-z*z*z-y*y;
				if(x>=0) m = min(m , x+y+z);
			}
		}
		cout << m << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  for (int E; cin >> E, E != 0; ) {
    int m = INF;
    for (int z = 0; z * z * z <= E; z++)
      for (int y = 0; y * y <= E; y++) {
        int x = E - y * y - z * z * z;
        if (x < 0) break;
        m = min(m, x + y + z);
    }

    cout << m << endl;

  }
  
  
  return 0;
}