import sys



inf = 1<<30

w = 100



def solve():

    while 1:

        e = int(sys.stdin.readline().rstrip())



        if e == 0:

            return



        ans = inf



        z0 = int(e**(1/3))



        for z in range(max(0, z0 - w), z0 + w):

            if e - z**3 < 0:

                break



            y0 = int((e - z**3)**0.5)

            for y in range(max(0, y0 - w), y0 + w):

                x = e - z**3 - y**2



                if x < 0:

                    break



                ans = min(ans, x + y + z)



        print(ans)



if __name__ == '__main__':

    solve()
import sys



inf = 1<<30

lim = 10**5



def solve():

    cubics = [x**3 for x in range(100 + 1)]



    while 1:

        e = int(sys.stdin.readline().rstrip())



        if e == 0:

            return



        ans = inf



        for z, c in enumerate(cubics):

            if c > e:

                break

            y = int((e - c)**0.5)

            x = e - c - y**2

            ans = min(ans, x + y + z)



        print(ans)



if __name__ == '__main__':

    solve()
import sys

inf = 1 << 30
w = 100


def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())
        if e == 0:
            return
        ans = inf
        z0 = int(e ** (1 / 3))
        for z in range(max(0, z0 - w), z0 + w):
            if e - z**3 < 0:
                break
            y0 = int((e - z**3) ** 0.5)
            for y in range(max(0, y0 - w), y0 + w):
                x = e - z**3 - y**2
                if x < 0:
                    break
                ans = min(ans, x + y + z)
        print(ans)


if __name__ == "__main__":
    solve()

import sys

inf = 1 << 30
lim = 10**5


def solve():
    cubics = [x**3 for x in range(100 + 1)]
    while 1:
        e = int(sys.stdin.readline().rstrip())
        if e == 0:
            return
        ans = inf
        for z, c in enumerate(cubics):
            if c > e:
                break
            y = int((e - c) ** 0.5)
            x = e - c - y**2
            ans = min(ans, x + y + z)
        print(ans)


if __name__ == "__main__":
    solve()

-w = 100 +lim = 10**5 +    cubics = [x**3 for x in range(100 + 1)] -        z0 = int(e ** (1 / 3)) -        for z in range(max(0, z0 - w), z0 + w): -            if e - z**3 < 0: +        for z, c in enumerate(cubics): +            if c > e: -            y0 = int((e - z**3) ** 0.5) -            for y in range(max(0, y0 - w), y0 + w): -                x = e - z**3 - y**2 -                if x < 0: -                    break -                ans = min(ans, x + y + z) +            y = int((e - c) ** 0.5) +            x = e - c - y**2 +            ans = min(ans, x + y + z)