#include <bits/stdc++.h>
const long long INF = 1LL << 62;
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long ans = INF;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      ans = min(ans, (i - 1) + (N / i - 1));
    }
  }
  cout << ans << endl;
}
