n = int(eval(input()))

x = int(n**0.5)

while n%x!=0:

    x-=1

x,y = x-1, n//x -1

print((x+y))
n = int(eval(input()))

x = int(n**0.5)

while n%x!=0: x-= 1

y = n//x

print((x-1+y-1))
n = int(eval(input()))
x = int(n**0.5)
while n % x != 0:
    x -= 1
x, y = x - 1, n // x - 1
print((x + y))

n = int(eval(input()))
x = int(n**0.5)
while n % x != 0:
    x -= 1
y = n // x
print((x - 1 + y - 1))

-x, y = x - 1, n // x - 1 -print((x + y)) +y = n // x +print((x - 1 + y - 1))