from collections import Counter,defaultdict,deque

import sys,bisect,math,itertools,string,queue

from heapq import heappop, heappush

sys.setrecursionlimit(10**8)

mod = 10**9+7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))



n = inp()

res = float('inf')

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

    if (n/i).is_integer():

        res = min(res, i + n/i)

print((int(res-2)))

from collections import Counter,defaultdict,deque

import sys,bisect,math,itertools,string,queue

from heapq import heappop, heappush

sys.setrecursionlimit(10**8)

mod = 10**9+7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))



n = inp()

res = float('inf')

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

    if n%i == 0:

        res = min(res, i + n/i)

print((int(res-2)))

from collections import Counter, defaultdict, deque
import sys, bisect, math, itertools, string, queue
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9 + 7


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


def inpl_str():
    return list(sys.stdin.readline().split())


def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
res = float("inf")
for i in range(1, 2 * 10**6):
    if (n / i).is_integer():
        res = min(res, i + n / i)
print((int(res - 2)))

from collections import Counter, defaultdict, deque
import sys, bisect, math, itertools, string, queue
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9 + 7


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


def inpl_str():
    return list(sys.stdin.readline().split())


def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
res = float("inf")
for i in range(1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        res = min(res, i + n / i)
print((int(res - 2)))

-for i in range(1, 2 * 10**6): -    if (n / i).is_integer(): +for i in range(1, int(math.sqrt(n)) + 1): +    if n % i == 0: