import math

N = int(eval(input()))



a = math.floor(N ** 0.5) + 1

ans = N + 1

for i in range(1, a):

  j = N // i

  if i * j == N and i + j - 2 < ans:

    ans = i + j - 2

  

print(ans)
import math

N = int(eval(input()))

a = math.floor(N ** 0.5)



ans = N

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

  if N % x != 0: continue

  y = N // x

  if ans > x + y - 2:

    ans = x + y - 2

print(ans)
import math

N = int(eval(input()))
a = math.floor(N**0.5) + 1
ans = N + 1
for i in range(1, a):
    j = N // i
    if i * j == N and i + j - 2 < ans:
        ans = i + j - 2
print(ans)

import math

N = int(eval(input()))
a = math.floor(N**0.5)
ans = N
for x in range(1, a + 1):
    if N % x != 0:
        continue
    y = N // x
    if ans > x + y - 2:
        ans = x + y - 2
print(ans)

-a = math.floor(N**0.5) + 1 -ans = N + 1 -for i in range(1, a): -    j = N // i -    if i * j == N and i + j - 2 < ans: -        ans = i + j - 2 +a = math.floor(N**0.5) +ans = N +for x in range(1, a + 1): +    if N % x != 0: +        continue +    y = N // x +    if ans > x + y - 2: +        ans = x + y - 2