#include <stdio.h>

int main(){
    int x,y,z,i,j,e[i],m[i];
    i=0;
    scanf("%d",&e[0]);
    while (e[i]!=0) {i++; scanf("%d",&e[i]);}
    
    if (e[0]!=0) {
        for (j=0;j<i;j++) {
            m[j]=1000000;
            for (z=0;z<=100;z++) {
                for (y=0;y<=1000;y++) {
                    x=e[j]-z*z*z-y*y;
                    if (x+y+z<m[j] && x>=0) {m[j]=x+y+z;}
                }
            }
            printf("%d\n",m[j]);
        }
    }

    return 0;
}