# C - Walk on Multiplication Table

# https://atcoder.jp/contests/abc144/tasks/abc144_c



n = int(eval(input()))



ans = 10 ** 12

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

  if n % i == 0:

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



print((ans - 2))
# C - Walk on Multiplication Table

# https://atcoder.jp/contests/abc144/tasks/abc144_c



n = int(eval(input()))



ans = n

for i in range(1, int(n**.5) + 2):

  if n % i == 0:

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



print(ans)
# C - Walk on Multiplication Table
# https://atcoder.jp/contests/abc144/tasks/abc144_c
n = int(eval(input()))
ans = 10**12
for i in range(1, 10**6 + 1):
    if n % i == 0:
        ans = min(ans, n // i + i)
print((ans - 2))

# C - Walk on Multiplication Table
# https://atcoder.jp/contests/abc144/tasks/abc144_c
n = int(eval(input()))
ans = n
for i in range(1, int(n**0.5) + 2):
    if n % i == 0:
        ans = min(ans, n // i + i - 2)
print(ans)

-ans = 10**12 -for i in range(1, 10**6 + 1): +ans = n +for i in range(1, int(n**0.5) + 2): -        ans = min(ans, n // i + i) -print((ans - 2)) +        ans = min(ans, n // i + i - 2) +print(ans)