/*
AizuOnline A2012
Title:Space Coconut Crab
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section
int n;
//
int sq_lin(int x)
{
  int q2;

  q2=(int)sqrt(x);
  return(q2+x-q2*q2);
}

main()
{
  int i,j,q3,sum,summin;
 
  while(scanf("%d",&n) && n)
    {
      q3=round(pow((double)n,1.0/3));
      if(q3*q3*q3>n)q3--;

      summin=999999;
      for(i=q3;i>=0;i--)
	{
	sum = sq_lin(n-i*i*i);
        // printf("3j:%d\n",i);
        // printf("sm:%d\n",sum);
	if(sum+i < summin)
	  summin=sum+i;
	}
      printf("%d\n",summin);
    }
return(0);
}