#include <bits/stdc++.h>
int main() {
  long long int N;
  scanf("%ld", &N);
  long long int ans = 10000000000000000;
  long long int a, b;
  for (long long int i = 1; i <= 1000000; i++) {
    if (N % i == 0) {
      a = i;
      b = N / a;
      if (ans > a + b - 2) {
        ans = a + b - 2;
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
