#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  int min_num;
  int min_ans = 1001001001;
  int A, B;
  for (int i = 2; i < 1000000000001; i++) {
    if (n % i == 0) {
      a = i;
      b = n / i;
      min_num = abs(a - b);
      if (min_num < min_ans) {
        min_ans = min_num;
        A = a;
        B = b;
      }
    }
  }
  if (min_ans == 1001001001)
    cout << n - 1 << endl;
  else
    cout << A + B - 2 << endl;
  return 0;
}
