#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A, B, C, D;
  cin >> N;
  A = 0;
  B = N;
  C = 1;
  D = 1;
  while (C * D < N) {
    C++;
    D++;
  }
  for (int i = 1; i < A; i++) {
    A = i;
    if (N % A == 0 & N / A < B) {
      if (B == A) {
        break;
      }
      B = N / A;
    }
  }
  A = N / B;
  cout << (A - 1) + (B - 1) << endl;
}
