//
//  main.c
//  Space Coconut Grab
//
//  Created by x15071xx on 2016/06/09.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    while (1) {
        
        int x=0,y=0,z=0;
        int e,m=99999;
        
        scanf("%d",&e);
        
        if (e==0) {
            continue;
        }
        
        for (z=0; z*z*z <= e; z++) {
            for (y=0; y*y + z*z*z <= e; y++) {
                x = e - z*z*z - y*y;
                if (m > x+y+z) { m = x+y+z; }
            }
        }
        
        printf("%d\n",m);
        
    }
    return 0;
}