N = int(eval(input()))

sqN = int(N**0.5)+1

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

    if N % i == 0:

        ans = i+N//i

        break



print((ans-2))
# 約数s

def make_divisors(n):

    divisors = []

    ret = []

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

        if n % i == 0:

            ret.append((i,n//i))

    return ret



if __name__ == "__main__":

    n = int(eval(input()))

    ret = make_divisors(n)

    # print(ret)

    ans = 10**18

    for a,b in ret:

        ans = min(a+b, ans)

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

# 約数s
def make_divisors(n):
    divisors = []
    ret = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ret.append((i, n // i))
    return ret


if __name__ == "__main__":
    n = int(eval(input()))
    ret = make_divisors(n)
    # print(ret)
    ans = 10**18
    for a, b in ret:
        ans = min(a + b, ans)
    print((ans - 2))

-N = int(eval(input())) -sqN = int(N**0.5) + 1 -for i in range(sqN, 0, -1): -    if N % i == 0: -        ans = i + N // i -        break -print((ans - 2)) +# 約数s +def make_divisors(n): +    divisors = [] +    ret = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            ret.append((i, n // i)) +    return ret + + +if __name__ == "__main__": +    n = int(eval(input())) +    ret = make_divisors(n) +    # print(ret) +    ans = 10**18 +    for a, b in ret: +        ans = min(a + b, ans) +    print((ans - 2))