#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T x) {
  std::cout << x << " ";
}
template <typename T>
void println(T x) {
  std::cout << x << "\n";
}
signed main(void) {
  long long N;
  cin >> N;
  long long ans = N;
  long long tmp;
  for (long long i = 1; i < (sqrt(N) + 1); i++) {
    if (N % i == 0) {
      tmp = i + N / i - 2;
      ans = min(ans, tmp);
    }
  }
  print(ans);
}
