N = int(eval(input()))

ans = 10 ** 20

for i in range(1, 10 ** 6 + 1):

    if i ** 2 > N: break

    if N % i == 0:

        ans = min(ans, i + N // i - 2)

print(ans)
import sys

def solve():

    N = int(eval(input()))

    moveN = 10000000000000000000

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

        if i ** 2 > N: break

        if N % i == 0:

            moveN = min(i + (N // i) - 2, moveN)

    print(moveN)



    return 0



if __name__ == "__main__":

    solve()
N = int(eval(input()))
ans = 10**20
for i in range(1, 10**6 + 1):
    if i**2 > N:
        break
    if N % i == 0:
        ans = min(ans, i + N // i - 2)
print(ans)

import sys


def solve():
    N = int(eval(input()))
    moveN = 10000000000000000000
    for i in range(1, N + 1):
        if i**2 > N:
            break
        if N % i == 0:
            moveN = min(i + (N // i) - 2, moveN)
    print(moveN)
    return 0


if __name__ == "__main__":
    solve()

-N = int(eval(input())) -ans = 10**20 -for i in range(1, 10**6 + 1): -    if i**2 > N: -        break -    if N % i == 0: -        ans = min(ans, i + N // i - 2) -print(ans) +import sys + + +def solve(): +    N = int(eval(input())) +    moveN = 10000000000000000000 +    for i in range(1, N + 1): +        if i**2 > N: +            break +        if N % i == 0: +            moveN = min(i + (N // i) - 2, moveN) +    print(moveN) +    return 0 + + +if __name__ == "__main__": +    solve()