import math

n=int(eval(input()))

ans=n-1

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

  if n%i==0:

    ans=min(ans,(i-1)+(n//i)-1)

print(ans)
from math import sqrt

n=int(eval(input()))

ans=float('inf')

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

  if n%i==0:

    res=i+n//i-2

    ans=min(ans,res)

print(ans)
import math

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

from math import sqrt

n = int(eval(input()))
ans = float("inf")
for i in range(1, int(sqrt(n)) + 1):
    if n % i == 0:
        res = i + n // i - 2
        ans = min(ans, res)
print(ans)

-import math +from math import sqrt -ans = n - 1 -for i in range(2, int(math.sqrt(n)) + 1): +ans = float("inf") +for i in range(1, int(sqrt(n)) + 1): -        ans = min(ans, (i - 1) + (n // i) - 1) +        res = i + n // i - 2 +        ans = min(ans, res)