N = int(input())
if N%2==1:
  print(N-1)
else:
  ans = []
  for i in range(1,N):
    for j in range(1,N):
      cnt=0
      if i*j==N:
        cnt +=i-1
        cnt +=j-1
        ans.append(str(cnt))
  ans=min(ans)
  print(ans)
