n=int(eval(input()))

mini=float('inf')

for i in range(1,int(n**0.5)+1):

    if n%i==0:

        mini=min(i+(n/i)-2,mini)

print((int(mini)))
n=int(eval(input()))

def make_divisors(n):

    divisors = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    # divisors.sort()

    return divisors

lis=make_divisors(n)

x=lis[-1]

if n%x**2==0:

    print((x*2-2))

    exit()

print((lis[-1]+lis[-2]-2))
n = int(eval(input()))
mini = float("inf")
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        mini = min(i + (n / i) - 2, mini)
print((int(mini)))

n = int(eval(input()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort()
    return divisors


lis = make_divisors(n)
x = lis[-1]
if n % x**2 == 0:
    print((x * 2 - 2))
    exit()
print((lis[-1] + lis[-2] - 2))

-mini = float("inf") -for i in range(1, int(n**0.5) + 1): -    if n % i == 0: -        mini = min(i + (n / i) - 2, mini) -print((int(mini))) + + +def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append(i) +            if i != n // i: +                divisors.append(n // i) +    # divisors.sort() +    return divisors + + +lis = make_divisors(n) +x = lis[-1] +if n % x**2 == 0: +    print((x * 2 - 2)) +    exit() +print((lis[-1] + lis[-2] - 2))