#include<stdio.h>
#include<math.h>
#define min(x,y) ((x)<(y)?(x):(y))
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int main(void){
    while(1){
        int e; scanf("%d",&e);
        if(e==0) break;
        int min=e;
        for(int z=0;z*z*z<=e;z++){
            for(int y=0;y*y+z*z*z<=e;y++){
                int x=e-z*z*z-y*y;
                if(min>x+y+z) min=x+y+z;
            }
        }
        printf("%d\n",min);
    }
}

