#include <iostream>
using namespace std;
int main() {
    int e;
    while (cin >> e, e) {
        int mn = e;
        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;
                mn = min(x+y+z,mn);
            }
        }
        cout << mn << endl;
    }
    return 0;
}
