N = int(eval(input()))

i = int(N**0.5)

while N%i!=0:

  i -= 1

print((i+N//i-2))
def solve():

    N = int(eval(input()))

    n = int(N**0.5)+1

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

        if N%i==0:

            ans = i+N//i-2

            break

    return ans

print((solve()))
N = int(eval(input()))
i = int(N**0.5)
while N % i != 0:
    i -= 1
print((i + N // i - 2))

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


print((solve()))

-N = int(eval(input())) -i = int(N**0.5) -while N % i != 0: -    i -= 1 -print((i + N // i - 2)) +def solve(): +    N = int(eval(input())) +    n = int(N**0.5) + 1 +    for i in range(n, 0, -1): +        if N % i == 0: +            ans = i + N // i - 2 +            break +    return ans + + +print((solve()))