#include <stdio.h>
typedef long long ll;
int main(void)
{
    int e;
    while (scanf("%d", &e), e) {
        int res=(1<<29), x, y, z, m;
        ll tz, ty;
        for(z=0;(tz=(ll)z*z*z)<=e;++z) for(y=0;tz+(ty=(ll)y*y)<=e;++y) {
            x=e-ty-tz;
            m=x+y+z;
            if (m<res) res=m;
        }
        printf("%d\n", res);
    }
    return 0;
}