#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int e;
  while (cin >> e && e != 0) {
    int m = e;
    for (int z=0; z*z*z <= e; z++) {
      int y = (int)sqrt(e - z*z*z);
      int x = e - (y*y + z*z*z);
      m = min(m, x+y+z);
    }
    cout << m << endl;
  }
  return 0;
}