#include using namespace std; typedef long long ll; int main() { ll e; while(cin>>e,e) { ll ans=(1LL<<62); for (ll z=0;z*z*z<=e;++z) for (ll y=0;z*z*z+y*y<=e;++y) { ll x=e-z*z*z-y*y; ans