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