N = int(eval(input()))





def dist(i, j):

    return i + j - 2





min = 10 ** 24

i = 1

while (i ** 2) <= N:

    if 0 == N % i:

        j = N // i

        d = dist(i, j)

        if min > d:

            min = d

    i += 1

print(d)

import math

n = int(eval(input()))



ans = 0

for i in range(math.ceil(math.sqrt(n) + 1))[:0:-1]:

    if 0 == n % i:

        ans = i

        break

ans_partner = n // ans

print((ans + ans_partner - 2))

N = int(eval(input()))


def dist(i, j):
    return i + j - 2


min = 10**24
i = 1
while (i**2) <= N:
    if 0 == N % i:
        j = N // i
        d = dist(i, j)
        if min > d:
            min = d
    i += 1
print(d)

import math

n = int(eval(input()))
ans = 0
for i in range(math.ceil(math.sqrt(n) + 1))[:0:-1]:
    if 0 == n % i:
        ans = i
        break
ans_partner = n // ans
print((ans + ans_partner - 2))

-N = int(eval(input())) +import math - -def dist(i, j): -    return i + j - 2 - - -min = 10**24 -i = 1 -while (i**2) <= N: -    if 0 == N % i: -        j = N // i -        d = dist(i, j) -        if min > d: -            min = d -    i += 1 -print(d) +n = int(eval(input())) +ans = 0 +for i in range(math.ceil(math.sqrt(n) + 1))[:0:-1]: +    if 0 == n % i: +        ans = i +        break +ans_partner = n // ans +print((ans + ans_partner - 2))