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