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