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