#include <bits/stdc++.h>
int main() {
  long N, a, walk, walkmini, j;
  scanf("%ld", &N);
  walkmini = N - 1;
  for (long i = 1; i <= sqrt(N); i++) {
    a = N % i;
    if (a == 0) {
      j = N / i;
      walk = (i - 1) + (j - 1);
      if (walkmini > walk) {
        walkmini = walk;
      }
    }
  }
  printf("%ld", walkmini);
}
