#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = 1; i * i < n; ++i)
    if (n % i == 0) v.push_back(i);
  long long mn = 999999999999;
  for (long long i : v)
    if (n / i + i < mn) mn = n / i + i;
  cout << mn - 2 << endl;
}
