#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a;
  a = sqrt(N) / 1;
  bool f = false;
  for (int i = a; i > 0; i--) {
    for (int j = a; j <= N; j++) {
      if (i * j == N) {
        cout << i + j - 2 << endl;
        f = true;
        break;
      }
    }
    if (f) {
      break;
    }
  }
}
