#include <bits/stdc++.h>
using namespace std;
long long sqr(long long x) { return (long long)x * x; }
long long tri(long long x) {
  if (x < 0) return 0;
  return (long long)x * (x + 1) / 2;
}
long long calc(long long n, long long s, long long x, long long y) {
  long long res = 2LL * s * (s + 1) + 1;
  if (x - s < 1) res -= sqr(s - x + 1);
  if (y - s < 1) res -= sqr(s - y + 1);
  if (x + s > n) res -= sqr(x + s - n);
  if (y + s > n) res -= sqr(y + s - n);
  if (x - s < 1 && y - s < 1) res += tri(s - 1 - (x - 1 + y - 1));
  if (x - s < 1 && y + s > n) res += tri(s - 1 - (x - 1 + n - y));
  if (x + s > n && y - s < 1) res += tri(s - 1 - (n - x + y - 1));
  if (x + s > n && y + s > n) res += tri(s - 1 - (n - x + n - y));
  if (res > (long long)n * n) fprintf(stderr, "error\n");
  return res;
}
int main() {
  int n, x, y, c;
  scanf("%d%d%d%d", &n, &x, &y, &c);
  long long head = 0;
  long long tail = 2 * n - 1;
  while (head <= tail) {
    int mid = (head + tail) / 2;
    if (calc(n, mid, x, y) >= c) {
      tail = mid - 1;
    } else {
      head = mid + 1;
    }
  }
  printf("%I64d\n", tail + 1);
  return 0;
}
