N = int(eval(input()))

from math import sqrt

ab_add = []

for i in range(1, int(sqrt(N)) + 1):

    if N % i == 0:

        ab_add.append(i + (N // i) - 2)

print((min(ab_add)))

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 + n // i) - 2)

            if i != n // i:

                divisors.append((n // i + i) - 2)



    divisors.sort()

    return divisors





div = make_divisors(N)

print((min(div)))

N = int(eval(input()))
from math import sqrt

ab_add = []
for i in range(1, int(sqrt(N)) + 1):
    if N % i == 0:
        ab_add.append(i + (N // i) - 2)
print((min(ab_add)))

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 + n // i) - 2)
            if i != n // i:
                divisors.append((n // i + i) - 2)
    divisors.sort()
    return divisors


div = make_divisors(N)
print((min(div)))

-from math import sqrt -ab_add = [] -for i in range(1, int(sqrt(N)) + 1): -    if N % i == 0: -        ab_add.append(i + (N // i) - 2) -print((min(ab_add))) + +def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append((i + n // i) - 2) +            if i != n // i: +                divisors.append((n // i + i) - 2) +    divisors.sort() +    return divisors + + +div = make_divisors(N) +print((min(div)))