#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, n, count, x, y, tmp;
  double d;
  cin >> n;
  tmp = (long long)sqrt(n);
  for (i = tmp; i > 1; i--) {
    if (n % i == 0) {
      break;
    }
  }
  cout << n / i + i - 2;
  return 0;
}
