import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int e, rest, ans;

    while (true) {
        e = readln.chomp.to!int;

        if (!e) break;

        ans = 1<<30;

        for(int z = 0; z^^3 <= e; ++z) {
            rest = e - z^^3;
            for(int y = 0; y^^2 <= rest; ++y) {
                int x = rest - y^^2;

                ans = min(ans, x + y + z);
            }
        }

        writeln(ans);
    }
}