N = int(eval(input()))

i = 1

ans = float("inf")

while i * i <= N:

  if N % i == 0:

    a = i

    b = int(N / i)

    ans = min(ans,(a-1) + (b-1))

  i += 1

print(ans)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np

N = int(read())

U = 10**6 + 100

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

div = x[N%x==0]

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

print(ans)
N = int(eval(input()))
i = 1
ans = float("inf")
while i * i <= N:
    if N % i == 0:
        a = i
        b = int(N / i)
        ans = min(ans, (a - 1) + (b - 1))
    i += 1
print(ans)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(read())
U = 10**6 + 100
x = np.arange(1, U, dtype=np.int64)
div = x[N % x == 0]
ans = (div + (N // div)).min() - 2
print(ans)

-N = int(eval(input())) -i = 1 -ans = float("inf") -while i * i <= N: -    if N % i == 0: -        a = i -        b = int(N / i) -        ans = min(ans, (a - 1) + (b - 1)) -    i += 1 +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +import numpy as np + +N = int(read()) +U = 10**6 + 100 +x = np.arange(1, U, dtype=np.int64) +div = x[N % x == 0] +ans = (div + (N // div)).min() - 2