#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  long long N;
  long long ret = 1e18;
  cin >> N;
  long long max = (long long)sqrt(N);
  for (long long k = max; k > 0; k--) {
    if (N % k == 0) {
      ret = N / k + k - 2;
      break;
    }
  }
  cout << ret << endl;
  return EXIT_SUCCESS;
}
