import numpy as np



def main():

    N = int(eval(input()))



    INF = 10**6 + 100



    x = np.arange(1,INF,dtype=np.int64)

    div = x[N % x == 0]

    #print(div)

    #print(N // div)

    

    ans = (div + N//div).min() - 2

    print(ans)





if __name__ == "__main__":

    main()

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



from math import sqrt



def divisor_enumeration(n):

    div = []

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

        if n % i == 0:

            if n // i != i:

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

            else:

                div.append((i, i))

        

    return div





def main():

    N = int(readline())



    d = divisor_enumeration(N)

    

    ans = 10**15

    for x, y in d:

        ans = min(ans, x + y - 2)



    print(ans)





if __name__ == "__main__":

    main()

import numpy as np


def main():
    N = int(eval(input()))
    INF = 10**6 + 100
    x = np.arange(1, INF, dtype=np.int64)
    div = x[N % x == 0]
    # print(div)
    # print(N // div)
    ans = (div + N // div).min() - 2
    print(ans)


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from math import sqrt


def divisor_enumeration(n):
    div = []
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            if n // i != i:
                div.append((i, n // i))
            else:
                div.append((i, i))
    return div


def main():
    N = int(readline())
    d = divisor_enumeration(N)
    ans = 10**15
    for x, y in d:
        ans = min(ans, x + y - 2)
    print(ans)


if __name__ == "__main__":
    main()

-import numpy as np +import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +from math import sqrt + + +def divisor_enumeration(n): +    div = [] +    for i in range(1, int(sqrt(n)) + 1): +        if n % i == 0: +            if n // i != i: +                div.append((i, n // i)) +            else: +                div.append((i, i)) +    return div -    N = int(eval(input())) -    INF = 10**6 + 100 -    x = np.arange(1, INF, dtype=np.int64) -    div = x[N % x == 0] -    # print(div) -    # print(N // div) -    ans = (div + N // div).min() - 2 +    N = int(readline()) +    d = divisor_enumeration(N) +    ans = 10**15 +    for x, y in d: +        ans = min(ans, x + y - 2)