#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int score;
  score = 1e9;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      score = min(i + N / i - 2, score);
    }
  }
  cout << score;
}
