n = int(eval(input()))

l = int(n**0.5)

while l:

    if n%l: l-=1

    else: break

print(((l-1)+(n//l-1)))
n = int(eval(input()))

x, y = 1, n

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

        if n%i==0: x = i

y = n//x

print((x+y-2))
n = int(eval(input()))
l = int(n**0.5)
while l:
    if n % l:
        l -= 1
    else:
        break
print(((l - 1) + (n // l - 1)))

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

-l = int(n**0.5) -while l: -    if n % l: -        l -= 1 -    else: -        break -print(((l - 1) + (n // l - 1))) +x, y = 1, n +for i in range(1, int(n**0.5) + 1): +    if n % i == 0: +        x = i +y = n // x +print((x + y - 2))