#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, a, b, i, flag = 0;
  cin >> n;
  long long int result = n - 1;
  for (i = 1; i <= sqrt(n); ++i) {
    if (!(n % i)) {
      a = i;
      b = n / i;
      flag = 1;
      result = min(result, ((a - 1) + (b - 1)));
    }
  }
  if (flag)
    cout << result << "\n";
  else
    cout << n - 1 << "\n";
  return 0;
}
