#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, k, j, min;
  cin >> A;
  k = A;
  j = 1;
  min = k + j - 2;
  for (int i = A; i >= pow(A, 0.5); i--) {
    if (A % i == 0) {
      k = A / i;
      j = A / k;
      if (min > k + j - 2) {
        min = k + j - 2;
      }
    }
  }
  cout << min << endl;
}
