output_description: Print the minimum number of moves needed to reach a square that contains the
  integer N.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: N = int(input())
  import copy
  
  n = copy.deepcopy(N)
  D = {}
  for i in range(2, 10**6 + 1):
      while N % i == 0:
          if i not in D:
              D[i] = 1
              N //= i
          else:
              D[i] += 1
              N //= i
  if N != 1:
      D[N] = 1
  D = list(D.items())
  # print(D)
  ANS = [1]
  for i in range(len(D)):
      ans = []
      for j in ANS:
          for k in range(D[i][1] + 1):
              ans.append(j * (D[i][0] ** k))
      # print(ans)
      ANS = ans
  # print(ANS)
  
  cnt = 10**12
  for i in ANS:
      if (i + (n // i)) - 2 < cnt:
          cnt = (i + (n // i)) - 2
  print(cnt)
  
problem_description: Statement
  
  Takahashi is standing on a multiplication table with infinitely many rows and
  columns.
  
  The square (i,j) contains the integer i \times j. Initially, Takahashi is
  standing at (1,1).
  
  In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
  
  Given an integer N, find the minimum number of moves needed to reach a square
  that contains N.
samples: [{"input": "10", "output": "5\n    \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n    \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n    \n\nBoth input and output may be enormous."}]