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