import numpy as np



N=int(eval(input()))

a=int(np.sqrt(N))

b=float('inf')

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

    if N%i==0:

        if i+N//i<b:

            ans=i



print((ans+N//ans-2))

# -*- coding: utf-8 -*-

import sys

from math import sqrt

sys.setrecursionlimit(10**9)

INF=10**18

MOD=10**9+7

def input(): return sys.stdin.readline().rstrip()



def main():

    N=int(eval(input()))

    tmp=INF

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

        if N%i==0:

            tmp=min(tmp,i+N//i)

    print((tmp-2))

    



if __name__ == '__main__':

    main()

import numpy as np

N = int(eval(input()))
a = int(np.sqrt(N))
b = float("inf")
for i in range(1, a + 1):
    if N % i == 0:
        if i + N // i < b:
            ans = i
print((ans + N // ans - 2))

# -*- coding: utf-8 -*-
import sys
from math import sqrt

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(eval(input()))
    tmp = INF
    for i in range(1, 10**6 + 1):
        if N % i == 0:
            tmp = min(tmp, i + N // i)
    print((tmp - 2))


if __name__ == "__main__":
    main()

-import numpy as np +# -*- coding: utf-8 -*- +import sys +from math import sqrt -N = int(eval(input())) -a = int(np.sqrt(N)) -b = float("inf") -for i in range(1, a + 1): -    if N % i == 0: -        if i + N // i < b: -            ans = i -print((ans + N // ans - 2)) +sys.setrecursionlimit(10**9) +INF = 10**18 +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().rstrip() + + +def main(): +    N = int(eval(input())) +    tmp = INF +    for i in range(1, 10**6 + 1): +        if N % i == 0: +            tmp = min(tmp, i + N // i) +    print((tmp - 2)) + + +if __name__ == "__main__": +    main()