import math

n=int(eval(input()))

ans=n

i=1

while(i<=math.sqrt(n)):

    if n%i==0:

        d=i+n/i-2

        ans=min(ans,d)

    i+=1

print((int(ans)))
from math import floor

from math import sqrt

n=int(eval(input()))

nn=floor(sqrt(n))

rest=n%nn

while rest!=0:

    nn-=1

    rest=n%nn

nnn=n/nn

print((int(nn+nnn-2)))
import math

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

from math import floor
from math import sqrt

n = int(eval(input()))
nn = floor(sqrt(n))
rest = n % nn
while rest != 0:
    nn -= 1
    rest = n % nn
nnn = n / nn
print((int(nn + nnn - 2)))

-import math +from math import floor +from math import sqrt -ans = n -i = 1 -while i <= math.sqrt(n): -    if n % i == 0: -        d = i + n / i - 2 -        ans = min(ans, d) -    i += 1 -print((int(ans))) +nn = floor(sqrt(n)) +rest = n % nn +while rest != 0: +    nn -= 1 +    rest = n % nn +nnn = n / nn +print((int(nn + nnn - 2)))