#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b;
  cin >> n;
  b = sqrt(n);
  for (long long int i = b; i > 0; i--) {
    if (n % i == 0) {
      a = i + n / i - 2;
      break;
    }
  }
  cout << a << endl;
  return 0;
}
