#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans, a, b;
  cin >> n;
  ans = n;
  for (long long i = 2; i * i <= n; i++) {
    a = i;
    if (b % i != 0) continue;
    b = n / i;
    ans = min(ans, a + b - 2);
  }
  cout << ans << endl;
}
