import math



n=int(eval(input()))

num=math.ceil(math.sqrt(n))



c=n+2

for i in range(1,num+1):

      if n%i==0 and (i+n//i)<c:

            a=i

            b=n//i

            c=a+b



print((a+b-2))

import math

n=int(eval(input()))

num=math.ceil(math.sqrt(n))

L=max([i for i in range(1,num+1) if n%i==0])

print((L+n//L-2))
import math

n = int(eval(input()))
num = math.ceil(math.sqrt(n))
c = n + 2
for i in range(1, num + 1):
    if n % i == 0 and (i + n // i) < c:
        a = i
        b = n // i
        c = a + b
print((a + b - 2))

import math

n = int(eval(input()))
num = math.ceil(math.sqrt(n))
L = max([i for i in range(1, num + 1) if n % i == 0])
print((L + n // L - 2))

-c = n + 2 -for i in range(1, num + 1): -    if n % i == 0 and (i + n // i) < c: -        a = i -        b = n // i -        c = a + b -print((a + b - 2)) +L = max([i for i in range(1, num + 1) if n % i == 0]) +print((L + n // L - 2))