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,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;
		int k;
		for(int z=0;(k=e-z*z*z)>=0;z++){
			int y=(int) sqrt(k)+0.00001;
			int x=k-y*y;
			mini=min(mini,x+y+z);
		}
		p(mini);
	}
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int E;

int calc2(){
  int ans = 5000000;
  REP(z, 100){
    int y = (int)(floor(sqrt(E - z))), x = E - y - z;
    if(y >= 0 && x >= 0){
      cout <<x <<", " <<y <<", " <<z <<", " <<x + y + z <<endl;
      ans = min(ans, x + y + z);
    }
  }
  return ans;
}

int calc(){
  int ans = 5000000;
  for(int z = 100; z >= 0; --z){
    if((int)(pow(z, 3)) > E) continue;
    for(int y = 1000; y >= 0; --y){
      int tmp = ((int)(pow(z, 3)) + (int)(pow(y, 2)));
      if(tmp > E) continue;
      int x = E - tmp;
      //return x + y + z;
      ans = min(ans, x + y + z);
    }
  }
  return ans;
}

int calc1(){
  int ans = 1e9 + 7;
  REP(y, 1001){
    if(y * y > E) continue;
    REP(z, 101){
      int tmp = (z * z * z + y * y);
      if(tmp > E) break;
      int x = E - tmp;
      ans = min(ans, x + y + z);
    }
  }
  return ans;
}

int main() {
  while(cin >>E && E) cout <<calc1() <<endl;
  //while(cin >>E && E) cout <<calc() <<endl;
  //while(cin >>E && E) cout <<calc2() <<endl;
  return 0;
}

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

int main(){
while(1){//start	
	
	int e;
	int ans = 10000000;
	cin >> e;
	
	if(e == 0) break;
	
	int x;
	for(int y = 0; y < 1000; y++){
		for(int z = 0; z < 100; z++){
			if(y*y + z*z > e)break;
			x = e - y*y - z*z*z;
			if(x + y*y + z*z*z > e) break;
			if(x >= 0 and x + y*y + z*z*z == e){
				ans = min(ans, x + y + z);
				//cout << "ans = " << ans << endl;
			}
		}
	}
	
	
	cout << ans << endl;
	
}//end	
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main(){
  int N, k;
  while(cin >> N && N > 0){
    int ans = -1;
    rep(i, 101){
      rep(j, 1001){
        k = N - j*j - i*i*i;
        if (k < 0) break;
        if(ans == -1) {
          ans = i + j + k;
        } else{
          if (ans > i + j + k) ans = i + j + k;
        }

      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

int main(){
  int e;
  while(cin >> e, e){
    int limz, ret = ( 1 << 30 );
    for(int z = 0 ; ( limz = z * z * z) <= e ; z++ ){
      for(int y = 0 ; limz + y * y <= e; y++){
        int x = e - limz - y * y;
        ret = min( x + y + z, ret);
      }
    }
    cout << ret << endl;
  }
}

C++: #include <iostream>

using namespace std;

int main() {
	int e;
	while (cin >> e) {
		if (e == 0) {
			break;
		}
		int i, j, k, m;
		bool hantei = false;
		for (m = 1; ; m++) {
			for (k = m; k >= 0; k--) {
				for (j = m-k; j >= 0; j--) {
					for (i = m-k-j; i >= 0; i--) {
						if (i+j*j+k*k*k == e) {
							hantei = true;
							break;
						}
					}
					if (hantei) {
						break;
					}
				}
				if (hantei) {
					break;
				}
			}
			if (hantei) {
				break;
			}
		}
		cout << m << endl;
	}
	return 0;
}

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

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

C++: 
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			int e = sc.nextInt();
			if (e == 0) break;
			int min = INF;
			for (int z=0;z*z*z<=e;z++) for (int y=0;y*y<=e-z*z*z;y++) {
				int x = e - z*z*z - y*y;
				min = min(min, x+y+z);
//				debug(z, y, x);
			}
			System.out.println(min);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int squ[1100];
int cub[110];

int main(){
	for(int i=0;i<=1000;i++){
		squ[i]=i*i;
	}
	for(int i=0;i<=100;i++){
		cub[i]=i*i*i;
	}
	while(1){
		cin>>n;
		if(n==0)break;
		int ans=INF;
		for(int i=0;i<=100&&cub[i]<=n;i++){
			for(int j=0;j<=1000&&squ[j]+cub[i]<=n;j++){
				ans=min(ans,i+j+(n-cub[i]-squ[j]));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}