/* 
   AOJ 2012
   Space Coconut Grab
   2015/7/24
*/

#include<stdio.h>
#define ENERGY_MAX 1000000

int calc_m(int energy)
{
  int x = 0, y = 0, z = 0, min = energy, cnt = 0, i;
  /* for(z = 0; z * z * z <= energy; z++); */
  /* z--; */
  for(z = 0; z * z * z <= energy; z++)
    {
      for(y = 0; y * y <= energy - z * z * z; y++)
	{
	  x = energy - z * z * z - y * y;
	  if(min > x + y + z)
	    {
	      min = x + y + z;
	    }
	}
    }
    
  //printf("--->cnt = %d\n", cnt);
  return min;
}

int main(void)
{
  int energy, m;
  while(1)
    {
      scanf("%d", &energy);
      if(energy == 0)
	{
	  break;
	}
      m = calc_m(energy);
      printf("%d\n", m);
    }
  return 0;
}