#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int count = 0;
  long long int min = 1e12;
  long long int j = 0;
  for (long long int i = 1; i <= n / 2 + 1; i++) {
    if (n % i == 0) {
      j = n / i;
      count = i + j - 2;
      if (min > count) min = count;
    }
  }
  cout << min << endl;
  return 0;
}
