#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e9 + 9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll best = n - 1;
  for (ll x = 1; x * x <= n; ++x) {
    if (n % x == 0) {
      best = min(best, x + n / x - 2);
    }
  }
  cout << best << '\n';
  return 0;
}
