#include <bits/stdc++.h>
int n, x, y, c;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long num_square(long long t) {
  long long cut_up = max(0, y + t - n);
  long long cut_left = max(0, t - x + 1);
  long long cut_right = max(0, x + t - n);
  long long cut_down = max(0, t - y + 1);
  long long cut_ur = max(0, x + t - n + y - n - 1);
  long long cut_ul = max(0, t + y - n - x + 1 - 1);
  long long cut_dr = max(0, t + x - n - y + 1 - 1);
  long long cut_dl = max(0, t - x + 1 - y + 1 - 1);
  long long total = 1 + 2 * t * (t + 1);
  total -= cut_up * cut_up;
  total -= cut_left * cut_left;
  total -= cut_right * cut_right;
  total -= cut_down * cut_down;
  total += cut_ur * (cut_ur + 1) / 2;
  total += cut_ul * (cut_ul + 1) / 2;
  total += cut_dr * (cut_dr + 1) / 2;
  total += cut_dl * (cut_dl + 1) / 2;
  return total;
}
int main() {
  scanf("%d %d %d %d", &n, &x, &y, &c);
  long long lo = 0;
  long long hi = 2 * n;
  while (hi != lo) {
    long long mid = lo + (hi - lo) / 2;
    long long s = num_square(mid);
    if (s >= c) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  printf("%d\n", lo);
  fflush(stdin);
  getchar();
}
