import math
n = int(input())
n1 = int(math.sqrt(n))
cnt = 10**18
for i in range(1, n1+1):
  if n % i == 0:
      j = (n/i) - 1
      ans = i-1
      cnt = min(cnt, j+ans)
  else:
    continue
print(int(cnt))