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<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

string reversed(string str){
  reverse(all(str));
  return str;
}

int npow(int n,int x){
  int res = 1;
  rep(i,x)res*=n;
  return res;
}


int func(int n){
  int res = INF;
  rep(i,1000){
    rep(j,1000){
      int m = n - npow(i,3) - npow(j,2);
      if(m>=0)chmin(res,i+j+m);
    }
  }
  return res;
}


int main(){
  int n;
  while(n=in()){
    cout << func(n) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>

using namespace std;

int pw (int n, int p) {
  if (n == 0) return 0;
  if (p == 0) return 1;
  if (p == 1) return n;
  return n * pw(n, p-1);
}

int computeM (int e) {
  
  int ret = e;
  
  // zが最も自由度の小さい数なので、zから決定していく。

  for(int y = 0; y <= sqrt(e); y++) {
    for(int z = 0; z <= sqrt(e); z++) {
      int temp = pw(y, 2) + pw(z, 3);
      int x = e - temp;
      if (x < 0) x = 0;
      if (x + temp == e) ret = min(x + y + z, ret);
    }
  }
  

  return ret;
}

int main (void) {
  int e, m;

  while (1) {
    cin >> e; if (e == 0) break;
    m = computeM(e);
    cout << m << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int x,y,z;
int e;
int solve(){
	z=  (int)(pow (e,1/3));
	y = (int)(sqrt(e - pow(z, 3)));
	x = (int)(e - pow(z, 3)-pow(y, 2)); 
	int minnum = x+y+z;
	return mininum;
};
int main(){
	int A[100000];
    int k = 0;
	while( cin>>e && e>0 )
	{
		A[k]=solve();
        k++;
	}
	for(int l = 0;l < k; l++)
    {
        cout<<A[l]<<endl;
    }
	return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        int ans = 1000000;
        for(int i=0; i < 100; i++){
            int j = sqrt(n - i*i*i);
            if(n < i*i*i + j*j) continue;
            ans = min(ans, i+j+(n- i*i*i - j*j));
        }
        cout << ans << endl;
    }
}

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 mainmain2(){
	int n;
	while(cin>>n,n){
		int ans=1;
		while(1){
			if(a[n]){
				cout<<a[n]<<endl;
				continue;
			}
			rep(i,ans){
				if(i*i*i>n) break;
				rep(j,ans-i){
					if(i*i*i+j*j>n) break;
					rep(k,ans-j){
						int t=i*i*i+j*j+k;
						if(t==n){
							a[n]=i+j+k;
							goto end;
						}
						else if(t>n) break;
						// int t=k*k*k+j*j+i;
						if(a[t]==0){
							a[t]=i+j+k;
						}
					}
				}
			}
			ans++;
			
		}
		end:
		cout<<a[n]<<endl;
	}
}



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

C++: #include<iostream>
#include<cstring>
#define x3(i) ((i)*(i)*(i))
#define x2(i) ((i)*(i))
using namespace std;

int main(){
  int e;
  while(cin>>e,e){
    int min=1<<30;
    for(int z=0;x3(z)<=e;z++){
      for(int y=0;x2(y)<=e;y++){
	int x=e-x3(z)-x2(y);
	if(x<0) continue;
	if(x+y+z < min) min = x+y+z;
      }
    }
    cout<<min<<endl;
  }
  return 0;
}