N = int(eval(input()))

root = int(N ** (1/2)) + 1

num = 1

for i in range(root, 0, -1):

    if N % i == 0:

        num = i

        break

num2 = N // num

print((num+num2-2))
import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



def make_divisors(n): # nの約数を列挙

    divisors = []

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

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)

    divisors.sort()

    return divisors



N = ir()

D = make_divisors(N)

answer = 10 ** 12

for d in D:

    e = N // d

    result = (d - 1) + (e - 1)

    if result < answer:

        answer = result



print(answer)

N = int(eval(input()))
root = int(N ** (1 / 2)) + 1
num = 1
for i in range(root, 0, -1):
    if N % i == 0:
        num = i
        break
num2 = N // num
print((num + num2 - 2))

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


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


N = ir()
D = make_divisors(N)
answer = 10**12
for d in D:
    e = N // d
    result = (d - 1) + (e - 1)
    if result < answer:
        answer = result
print(answer)

-N = int(eval(input())) -root = int(N ** (1 / 2)) + 1 -num = 1 -for i in range(root, 0, -1): -    if N % i == 0: -        num = i -        break -num2 = N // num -print((num + num2 - 2)) +import sys + +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) + + +def make_divisors(n):  # nの約数を列挙 +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append(i) +            if i != n // i: +                divisors.append(n // i) +    divisors.sort() +    return divisors + + +N = ir() +D = make_divisors(N) +answer = 10**12 +for d in D: +    e = N // d +    result = (d - 1) + (e - 1) +    if result < answer: +        answer = result +print(answer)