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))
n=int(eval(input()))





def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    divisors.sort()

    return divisors



L=make_divisors(n)



s=float('inf')

for i in L:

      s=min(s,i+(n//i))



print((s-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))

n = int(eval(input()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


L = make_divisors(n)
s = float("inf")
for i in L:
    s = min(s, i + (n // i))
print((s - 2))

-import math +n = int(eval(input())) -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)) + +def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append(i) +            if i != n // i: +                divisors.append(n // i) +    divisors.sort() +    return divisors + + +L = make_divisors(n) +s = float("inf") +for i in L: +    s = min(s, i + (n // i)) +print((s - 2))