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

const int MAX_E=1e6+10;

int e,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> e,e){
        ans=MAX_E;
        for (int z=0;z*z*z<=e;++z)
            for (int y=0;y*y+z*z*z<=e;++y)
                ans=min(ans,(e-y*y-z*z*z)+y+z);
        cout << ans << '\n';
    }
}
