N = int(eval(input()))

ans = float('inf')

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

    tmp = N / i

    if tmp.is_integer():

        if tmp == N:

            tmp_ans = N - 1

        else:

            tmp_ans = int(tmp) + i - 2

        if ans > tmp_ans:

            ans = tmp_ans

print(ans)
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



10

N = int(eval(input()))

divisors = make_divisors(N)

ans = float('inf')

div_len = len(divisors)

if div_len % 2 == 0:

    i = div_len // 2

    j = div_len // 2 - 1

    ans = divisors[i] + divisors[j] - 2

else:

    ans = divisors[div_len // 2] * 2 - 2

print(ans)
N = int(eval(input()))
ans = float("inf")
for i in range(1, int(N**0.5) + 1):
    tmp = N / i
    if tmp.is_integer():
        if tmp == N:
            tmp_ans = N - 1
        else:
            tmp_ans = int(tmp) + i - 2
        if ans > tmp_ans:
            ans = tmp_ans
print(ans)

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


10
N = int(eval(input()))
divisors = make_divisors(N)
ans = float("inf")
div_len = len(divisors)
if div_len % 2 == 0:
    i = div_len // 2
    j = div_len // 2 - 1
    ans = divisors[i] + divisors[j] - 2
else:
    ans = divisors[div_len // 2] * 2 - 2
print(ans)

+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 + + +10 +divisors = make_divisors(N) -for i in range(1, int(N**0.5) + 1): -    tmp = N / i -    if tmp.is_integer(): -        if tmp == N: -            tmp_ans = N - 1 -        else: -            tmp_ans = int(tmp) + i - 2 -        if ans > tmp_ans: -            ans = tmp_ans +div_len = len(divisors) +if div_len % 2 == 0: +    i = div_len // 2 +    j = div_len // 2 - 1 +    ans = divisors[i] + divisors[j] - 2 +else: +    ans = divisors[div_len // 2] * 2 - 2