# a+b-2

# N = a*b  よってNの約数を求める



N = int(eval(input()))

ans = N-1

for i in range(1, int(N**0.5+1)):

  if N//i*i == N:

    ans = min(ans, i+N//i-2)

print(ans)    

# a+b-2

# N = a*b  よってNの約数を求める

import numpy as np



N = int(eval(input()))

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)
# a+b-2
# N = a*b  よってNの約数を求める
N = int(eval(input()))
ans = N - 1
for i in range(1, int(N**0.5 + 1)):
    if N // i * i == N:
        ans = min(ans, i + N // i - 2)
print(ans)

# a+b-2
# N = a*b  よってNの約数を求める
import numpy as np

N = int(eval(input()))
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)

+import numpy as np + -ans = N - 1 -for i in range(1, int(N**0.5 + 1)): -    if N // i * i == N: -        ans = min(ans, i + N // i - 2) +U = 10**6 + 100 +x = np.arange(1, U, dtype=np.int64) +div = x[N % x == 0] +ans = (div + N // div).min() - 2