import math



N = int(eval(input()))



answer = N + 1

for a in range(1, math.floor(math.sqrt(N)) + 1):

    if  N % a == 0:

        answer = min(answer, int(a + N / a) - 2)

print(answer)
import math

N = int(eval(input()))

print((min([a + N // a - 2 for a in range(math.floor(math.sqrt(N)) + 1, 0, -1) if N % a == 0])))

import math

N = int(eval(input()))
answer = N + 1
for a in range(1, math.floor(math.sqrt(N)) + 1):
    if N % a == 0:
        answer = min(answer, int(a + N / a) - 2)
print(answer)

import math

N = int(eval(input()))
print(
    (
        min(
            [
                a + N // a - 2
                for a in range(math.floor(math.sqrt(N)) + 1, 0, -1)
                if N % a == 0
            ]
        )
    )
)

-answer = N + 1 -for a in range(1, math.floor(math.sqrt(N)) + 1): -    if N % a == 0: -        answer = min(answer, int(a + N / a) - 2) -print(answer) +print( +    ( +        min( +            [ +                a + N // a - 2 +                for a in range(math.floor(math.sqrt(N)) + 1, 0, -1) +                if N % a == 0 +            ] +        ) +    ) +)