#include <bits/stdc++.h>
const long long int mod = 1e9 + 7;
const int maxn = 2e5 + 50;
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a;
  a = 1e5 + 50;
  long long int tab[a];
  long long int nb;
  nb = -1;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      nb++;
      tab[nb] = i - 1 + (n / i - 1);
    }
  }
  long long int res;
  res = tab[0];
  for (long long int i = 0; i <= nb; i++) {
    res = min(res, tab[i]);
  }
  cout << res;
}
