#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long k = sqrt(n);
  for (long long i = k; i >= 1; i--) {
    if (n % i == 0) {
      cout << i + n / i - 2;
      return 0;
    }
  }
}
