n=int(eval(input()))

move=10**12

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

    if n%i==0:

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

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

num_i=0

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

    if n%i==0:

        num_i=i

num_j=n//num_i

print((num_i+num_j-2))
n = int(eval(input()))
move = 10**12
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        move = min(move, n // i + i - 2)
print(move)

n = int(eval(input()))
num_i = 0
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        num_i = i
num_j = n // num_i
print((num_i + num_j - 2))

-move = 10**12 +num_i = 0 -        move = min(move, n // i + i - 2) -print(move) +        num_i = i +num_j = n // num_i +print((num_i + num_j - 2))