import math

import itertools

n = int(eval(input()))

x = 1

for i in reversed(list(range(1, math.ceil(math.sqrt(n))+1))):

    if n % i == 0:

        x = n / i

        break



print((math.floor(x - 1 + n / x - 1)))
import itertools

import math

import fractions

import functools

n = int(eval(input()))



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

minimum = 10**20

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

    j = 0

    if n % i == 0:

        j = n / i

        minimum = min(minimum,i+j)



print((int(minimum-2)))
import math
import itertools

n = int(eval(input()))
x = 1
for i in reversed(list(range(1, math.ceil(math.sqrt(n)) + 1))):
    if n % i == 0:
        x = n / i
        break
print((math.floor(x - 1 + n / x - 1)))

import itertools
import math
import fractions
import functools

n = int(eval(input()))
maximum = math.ceil(math.sqrt(n))
minimum = 10**20
for i in range(1, maximum + 1):
    j = 0
    if n % i == 0:
        j = n / i
        minimum = min(minimum, i + j)
print((int(minimum - 2)))

+import itertools -import itertools +import fractions +import functools -x = 1 -for i in reversed(list(range(1, math.ceil(math.sqrt(n)) + 1))): +maximum = math.ceil(math.sqrt(n)) +minimum = 10**20 +for i in range(1, maximum + 1): +    j = 0 -        x = n / i -        break -print((math.floor(x - 1 + n / x - 1))) +        j = n / i +        minimum = min(minimum, i + j) +print((int(minimum - 2)))