#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>


int solve(int E) {
  int ans = INT_MAX, x, y, z;
  for (x = 0; x<=E; x++) {
    for (y = 0; y*y<=E; y++) {
      z = cbrt(E - x - y * y);
      if (!(x + y * y + z * z * z == E)) continue;
      if (x + y + z < ans) ans = (x + y + z);
    }
  }
  return ans;
}
	
int main(int argc, char *argv[])
{
  int d;
  while (fscanf(stdin, "%d", &d) && d != 0) {
    int ans = solve(d);
    printf("%d\n",ans);
  }
  return 0;
}