# a+b-2

# N = a*b  よってNの約数を求める

import numpy as np



N = int(eval(input()))

U = 10**6+100

x = np.arange(1, U, dtype=np.int64)

div = x[N%x==0]

ans = (div + N//div).min() - 2

print(ans)
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read 

input = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines  



def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append((i, n//i))

            

    # divisors.sort()

    return divisors



N = int(eval(input()))

div = make_divisors(N)



ans = 10**15

for a, b in div:

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

print(ans)  



# a+b-2
# N = a*b  よってNの約数を求める
import numpy as np

N = int(eval(input()))
U = 10**6 + 100
x = np.arange(1, U, dtype=np.int64)
div = x[N % x == 0]
ans = (div + N // div).min() - 2
print(ans)

import sys

sys.setrecursionlimit(10**7)
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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


N = int(eval(input()))
div = make_divisors(N)
ans = 10**15
for a, b in div:
    ans = min(ans, a + b - 2)
print(ans)

-# a+b-2 -# N = a*b  よってNの約数を求める -import numpy as np +import sys + +sys.setrecursionlimit(10**7) +read = sys.stdin.buffer.read +input = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines + + +def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append((i, n // i)) +    # divisors.sort() +    return divisors + -U = 10**6 + 100 -x = np.arange(1, U, dtype=np.int64) -div = x[N % x == 0] -ans = (div + N // div).min() - 2 +div = make_divisors(N) +ans = 10**15 +for a, b in div: +    ans = min(ans, a + b - 2)