#include <stdio.h>
#define min(a, b) ((a < b) ? a : b)

int main() {
    int x, y, z, e, ans;

    while (cin >> e) {
        if (!e) { break; }
        ans = e;

        for (z = 0; z*z*z <= e; z++) {
            for (y = 0; y*y + z*z*z <= e; y++) {
                x = e - y*y - z*z*z;
                ans = min(ans, x+y+z);
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}
