#include <bits/stdc++.h>
int main() {
  int i, n;
  int divisor[2];
  scanf("%d", &n);
  for (i = n / 2; i > 1; i--) {
    if (n % i == 0) {
      divisor[0] = i;
      divisor[1] = n / i;
      break;
    }
  }
  printf("%d", (divisor[0] - 1) + (divisor[1] - 1));
  return 0;
}
