n = int(eval(input()))



a = [1, n]



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

    j = n // i

    if n % i == 0 and a[0] + a[1] > i + j:

        a = [i, j]



print((a[0] - 1 + a[1] - 1))
n = int(eval(input()))



#(1,1)から一番長く移動しないといけないのは(1,n)の時

ans = n - 1



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

    if n % i == 0:

        ans = min(ans, i + int(n/i) - 2)



print(ans)
n = int(eval(input()))
a = [1, n]
for i in range(1, int(n**0.5) + 1):
    j = n // i
    if n % i == 0 and a[0] + a[1] > i + j:
        a = [i, j]
print((a[0] - 1 + a[1] - 1))

n = int(eval(input()))
# (1,1)から一番長く移動しないといけないのは(1,n)の時
ans = n - 1
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        ans = min(ans, i + int(n / i) - 2)
print(ans)

-a = [1, n] +# (1,1)から一番長く移動しないといけないのは(1,n)の時 +ans = n - 1 -    j = n // i -    if n % i == 0 and a[0] + a[1] > i + j: -        a = [i, j] -print((a[0] - 1 + a[1] - 1)) +    if n % i == 0: +        ans = min(ans, i + int(n / i) - 2) +print(ans)