# -*- coding: utf-8 -*-

n = int(eval(input()))



ans = pow(10, 30)

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

    if n / i == n // i:

        j = n // i

        if i + j - 2 < ans:

            ans = i + j - 2

print(ans)

# -*- coding: utf-8 -*-

n = int(eval(input()))



ans = [10 ** 14, 10 ** 14]

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

    if n % i == 0:

        tmp = n // i

        if tmp + i < sum(ans):

            ans = [i, tmp]

print((sum(ans) - 2))



# -*- coding: utf-8 -*-
n = int(eval(input()))
ans = pow(10, 30)
for i in range(1, int(pow(n, 0.5)) + 1):
    if n / i == n // i:
        j = n // i
        if i + j - 2 < ans:
            ans = i + j - 2
print(ans)

# -*- coding: utf-8 -*-
n = int(eval(input()))
ans = [10**14, 10**14]
for i in range(1, int(pow(n, 0.5)) + 1):
    if n % i == 0:
        tmp = n // i
        if tmp + i < sum(ans):
            ans = [i, tmp]
print((sum(ans) - 2))

-ans = pow(10, 30) +ans = [10**14, 10**14] -    if n / i == n // i: -        j = n // i -        if i + j - 2 < ans: -            ans = i + j - 2 -print(ans) +    if n % i == 0: +        tmp = n // i +        if tmp + i < sum(ans): +            ans = [i, tmp] +print((sum(ans) - 2))