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