#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A = 1000000000000, ansi = 0, ansj = 0;
  int B = 0;
  cin >> N;
  for (long i = 2; i * i <= N; i++) {
    if (N % i == 0) B = 1;
  }
  if (B == 0)
    cout << N - 1 << endl;
  else {
    for (long i = 2; i * i <= N; i++) {
      for (long j = 1; j * 2 <= N; j++) {
        if (i * j == N && abs(j - i) < A) {
          ansi = i;
          ansj = j;
          A = abs(j - i);
        }
      }
    }
    cout << ansi + ansj - 2 << endl;
  }
}
