#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i = 2;
  cin >> n;
  int m = 0;
  while (1) {
    if (n % i == 0) {
      if (m >= n / i)
        break;
      else
        m = i;
    }
    i++;
  }
  cout << m + n / m - 2 << endl;
  return 0;
}
