while True:

    e = int(eval(input()))

    if e == 0:

        break

    z, ans = 0, float('inf')

    for z in range(e):

        if z ** 3 > e:

            break

        else:

            r = e - z ** 3

            y = int(r ** 0.5)

            x = r - y ** 2

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

    print(ans)

while True:

    e = int(eval(input()))

    if e == 0:

        break

    z, ans = 0, float('inf')

    while z ** 3 <= e:

        r = e - z ** 3

        y = int(r ** 0.5)

        x = r - y ** 2

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

        z += 1

    print(ans)

while True:
    e = int(eval(input()))
    if e == 0:
        break
    z, ans = 0, float("inf")
    for z in range(e):
        if z**3 > e:
            break
        else:
            r = e - z**3
            y = int(r**0.5)
            x = r - y**2
            ans = min(ans, x + y + z)
    print(ans)

while True:
    e = int(eval(input()))
    if e == 0:
        break
    z, ans = 0, float("inf")
    while z**3 <= e:
        r = e - z**3
        y = int(r**0.5)
        x = r - y**2
        ans = min(ans, x + y + z)
        z += 1
    print(ans)

-    for z in range(e): -        if z**3 > e: -            break -        else: -            r = e - z**3 -            y = int(r**0.5) -            x = r - y**2 -            ans = min(ans, x + y + z) +    while z**3 <= e: +        r = e - z**3 +        y = int(r**0.5) +        x = r - y**2 +        ans = min(ans, x + y + z) +        z += 1