#include <bits/stdc++.h>
using namespace std;
vector<long> makePrimes(const long upper = 1000000) {
  vector<long> primes;
  long p[upper + 1];
  for (long i = 0; i < upper; i += 2) {
    p[i] = 0;
    p[i + 1] = i + 1;
  }
  p[1] = 0;
  p[2] = 2;
  primes.push_back(2);
  for (long i = 3; i < upper; i += 2) {
    if (p[i] == 0) {
      continue;
    }
    primes.push_back(i);
    for (long j = i * i; j < upper; j += (2 * i)) {
      p[j] = 0;
    }
  }
  return primes;
}
vector<long> primes = makePrimes();
unordered_map<long, int> factorize(long n) {
  unordered_map<long, int> factors;
  for (auto p : primes) {
    if (n == 1) {
      return factors;
    } else if (n % p == 0) {
      int e = 1;
      for (; n % p == 0; e++, n /= p)
        ;
      factors[p] = e;
    }
  }
  factors[n] = 1;
  return factors;
}
vector<long> getDivisors(long n) {
  unordered_map<long, int> factors = factorize(n);
  vector<long> d1 = {1};
  vector<long> d2;
  for (auto it = factors.cbegin(); it != factors.cend(); ++it) {
    d2.clear();
    int p = 1;
    int emax = it->second;
    for (int e = 0; e < it->second; ++e) {
      for (auto d : d1) {
        d2.push_back(p * d);
      }
      p *= it->first;
    }
    d1.swap(d2);
    d2.clear();
  }
  sort(d1.begin(), d1.end());
  return d1;
}
int main() {
  long n;
  cin >> n;
  vector<long> ds = getDivisors(n);
  long ans = n;
  for (auto d1 : ds) {
    if (d1 * d1 > n) {
      break;
    }
    int d2 = n / d1;
    if (d1 + d2 - 2 < ans) {
      ans = d1 + d2 - 2;
    }
  }
  cout << ans << endl;
  return 0;
}
