import sys





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n = int(input().rstrip('\n'))

    t = n

    mt = 10 ** 20

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

        if t % i == 0:

            mt = min(mt, (i - 1) + (t // i - 1))

    print(mt)





if __name__ == '__main__':

    solve()

import sys





def solve():

    sys.setrecursionlimit(2000)

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n = int(input().rstrip('\n'))

    mt = 10 ** 20

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

        if n % i == 0:

            mt = min(mt, i + (n // i) - 2)

    print(mt)





if __name__ == '__main__':

    solve()

import sys


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n = int(input().rstrip("\n"))
    t = n
    mt = 10**20
    for i in range(1, int(n**0.5) + 1):
        if t % i == 0:
            mt = min(mt, (i - 1) + (t // i - 1))
    print(mt)


if __name__ == "__main__":
    solve()

import sys


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10**9 + 7
    n = int(input().rstrip("\n"))
    mt = 10**20
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            mt = min(mt, i + (n // i) - 2)
    print(mt)


if __name__ == "__main__":
    solve()

+    sys.setrecursionlimit(2000) -    t = n -        if t % i == 0: -            mt = min(mt, (i - 1) + (t // i - 1)) +        if n % i == 0: +            mt = min(mt, i + (n // i) - 2)