import math



INF = 1e12

n = int(eval(input()))

cnt = INF

m = math.sqrt(n)



for i in range(1, math.ceil(m) + 1):

  if n % i == 0:

    j = n // i

    cnt = min(cnt, i + j - 2)

  else:

    continue



print(cnt)
from math import ceil



def divisors(n):

    res = []

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

        if n % i == 0:

            res.append(i)

            if i != n // i:

                res.append(n // i)

    return res



n = int(eval(input()))

divs = divisors(n)

ans = 10 ** 12

divs.sort()

for i in range(ceil(len(divs) / 2)):

    a = divs[i]

    b = divs[(i + 1) * (-1)]

    ans = min(ans, (a - 1) + (b - 1))



print(ans)
import math

INF = 1e12
n = int(eval(input()))
cnt = INF
m = math.sqrt(n)
for i in range(1, math.ceil(m) + 1):
    if n % i == 0:
        j = n // i
        cnt = min(cnt, i + j - 2)
    else:
        continue
print(cnt)

from math import ceil


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


n = int(eval(input()))
divs = divisors(n)
ans = 10**12
divs.sort()
for i in range(ceil(len(divs) / 2)):
    a = divs[i]
    b = divs[(i + 1) * (-1)]
    ans = min(ans, (a - 1) + (b - 1))
print(ans)

-import math +from math import ceil -INF = 1e12 + +def divisors(n): +    res = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            res.append(i) +            if i != n // i: +                res.append(n // i) +    return res + + -cnt = INF -m = math.sqrt(n) -for i in range(1, math.ceil(m) + 1): -    if n % i == 0: -        j = n // i -        cnt = min(cnt, i + j - 2) -    else: -        continue -print(cnt) +divs = divisors(n) +ans = 10**12 +divs.sort() +for i in range(ceil(len(divs) / 2)): +    a = divs[i] +    b = divs[(i + 1) * (-1)] +    ans = min(ans, (a - 1) + (b - 1)) +print(ans)