#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, tem, ans = LONG_MAX;
  cin >> n;
  for (int i = sqrt(n); i >= 1; i--) {
    if (n % i == 0) {
      tem = n / i;
      ans = tem - 1 + i - 1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
