import math

n = int(eval(input()))

p = 10 ** 12

m = math.floor(math.sqrt(n))



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

    if n % i == 0:

        j = n // i

        p = min(p,i-1+j-1)



print(p)
from math import sqrt

from math import floor

n = int(eval(input()))

ans = 10 ** 12

m = floor(sqrt(n))

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

    if n % i == 0:

        j = n // i

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

print(ans)
import math

n = int(eval(input()))
p = 10**12
m = math.floor(math.sqrt(n))
for i in range(1, m + 1):
    if n % i == 0:
        j = n // i
        p = min(p, i - 1 + j - 1)
print(p)

from math import sqrt
from math import floor

n = int(eval(input()))
ans = 10**12
m = floor(sqrt(n))
for i in range(1, m + 1):
    if n % i == 0:
        j = n // i
        ans = min(ans, i + j - 2)
print(ans)

-import math +from math import sqrt +from math import floor -p = 10**12 -m = math.floor(math.sqrt(n)) +ans = 10**12 +m = floor(sqrt(n)) -        p = min(p, i - 1 + j - 1) -print(p) +        ans = min(ans, i + j - 2) +print(ans)