import math

n=int(eval(input()))



for i in reversed(list(range(1,int(math.sqrt(n))+1))):

  if n%i == 0:

    ans = i+n//i-2

    break

print(ans)

import math

n=int(eval(input()))

r=int(math.sqrt(n))



while n%r!=0:

  r-=1

print((n//r+r-2))



import math

n = int(eval(input()))
for i in reversed(list(range(1, int(math.sqrt(n)) + 1))):
    if n % i == 0:
        ans = i + n // i - 2
        break
print(ans)

import math

n = int(eval(input()))
r = int(math.sqrt(n))
while n % r != 0:
    r -= 1
print((n // r + r - 2))

-for i in reversed(list(range(1, int(math.sqrt(n)) + 1))): -    if n % i == 0: -        ans = i + n // i - 2 -        break -print(ans) +r = int(math.sqrt(n)) +while n % r != 0: +    r -= 1 +print((n // r + r - 2))