import math

N = int(eval(input()))

ans = 10**12

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

  j = math.ceil(N/(i+1))

  if (1+i)*j == N:

    ans = min(i+j-1,ans)

  if i == 10**6 and ans == 10**12:

    ans = N-1

    break

print(ans)
N = int(eval(input()))

ans = 10**12

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

  j = N//i

  if i*j == N:

    ans = min(i+j-2,ans)

  if i == 10**6 and ans == 10**12:

    ans = N-1

    break

print(ans)
import math

N = int(eval(input()))
ans = 10**12
for i in range(1, 10**6 + 1):
    j = math.ceil(N / (i + 1))
    if (1 + i) * j == N:
        ans = min(i + j - 1, ans)
    if i == 10**6 and ans == 10**12:
        ans = N - 1
        break
print(ans)

N = int(eval(input()))
ans = 10**12
for i in range(1, 10**6 + 1):
    j = N // i
    if i * j == N:
        ans = min(i + j - 2, ans)
    if i == 10**6 and ans == 10**12:
        ans = N - 1
        break
print(ans)

-import math - -    j = math.ceil(N / (i + 1)) -    if (1 + i) * j == N: -        ans = min(i + j - 1, ans) +    j = N // i +    if i * j == N: +        ans = min(i + j - 2, ans)