#include <bits/stdc++.h>
int main(void) {
  long int N;
  int divider = 1;
  scanf("%ld", &N);
  for (int i = 1; i <= sqrt((double)N); i++) {
    if (N % i == 0) {
      divider = i;
    }
  }
  printf("%ld", divider + N / divider - 2);
  return 0;
}
