
#include <iostream>
using namespace std;

int main(int argc, char const *argv[]) {
	int count = 1000000;
	for (int i = 0; i < count; i++) {
		int e = 0;
		cin >> e;
		if (e == 0){
			return 0;
		}
		int min = e;
		for (int z = 0; z*z*z <= e; z++) {
			for (int y = 0; y*y <= e - z*z*z; y++) {
				int x = e - y*y - z*z*z;
				int m = x + y + z;
				if (m < min){
					min = m;
				}
			}
		} //
		cout << min << endl;
	} //
	return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <initializer_list>

using namespace std;

int main()
{
    int m, e, y, z;
    int min;
    while (cin >> e, e) {
        m = min = 1000000;
        for (z = 0; z <= 100; z++) {
            if (z*z*z > e)
                break;
            for (y = 0; y <= 1000; y++) {
                if (y*y + z*z*z > e) {
                    y--;
                    m = y + z + (e-y*y-z*z*z);
                    min = m < min ? m : min;
                    break;
                }
            }
        }
        cout << min << endl;
    }

    return 0;
}