import math



N = int(eval(input()))

rN = int(math.ceil(math.sqrt(N)))



for i in (list(range(rN,0,-1))):

    a=N//i

    if a*i==N:

        print((a+i-2))

        break
import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    N=I()

    ans=N

    

    M=10**6+5

    for i in range(1,M):

        if N%i==0:

            j=N//i

            temp=i+j-2

            ans=min(ans,temp)

            

    print(ans)

            

        



main()

import math

N = int(eval(input()))
rN = int(math.ceil(math.sqrt(N)))
for i in list(range(rN, 0, -1)):
    a = N // i
    if a * i == N:
        print((a + i - 2))
        break

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    N = I()
    ans = N
    M = 10**6 + 5
    for i in range(1, M):
        if N % i == 0:
            j = N // i
            temp = i + j - 2
            ans = min(ans, temp)
    print(ans)


main()

-import math +import sys -N = int(eval(input())) -rN = int(math.ceil(math.sqrt(N))) -for i in list(range(rN, 0, -1)): -    a = N // i -    if a * i == N: -        print((a + i - 2)) -        break +input = sys.stdin.readline + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N = I() +    ans = N +    M = 10**6 + 5 +    for i in range(1, M): +        if N % i == 0: +            j = N // i +            temp = i + j - 2 +            ans = min(ans, temp) +    print(ans) + + +main()