#include <bits/stdc++.h>
using namespace std;
int n, a, b;
long long cal(int x) {
  long long res = 1 + 2 * (long long)x * (x + 1);
  long long tmp;
  tmp = x + 1 - a - b;
  if (tmp > 0) res += tmp * (tmp + 1) / 2;
  tmp = x + a - b - n;
  if (tmp > 0) res += tmp * (tmp + 1) / 2;
  tmp = x + b - a - n;
  if (tmp > 0) res += tmp * (tmp + 1) / 2;
  tmp = x + a + b - 2 * n - 1;
  if (tmp > 0) res += tmp * (tmp + 1) / 2;
  tmp = x + 1 - a;
  if (tmp > 0) res -= tmp * tmp;
  tmp = x + 1 - b;
  if (tmp > 0) res -= tmp * tmp;
  tmp = x + a - n;
  if (tmp > 0) res -= tmp * tmp;
  tmp = x + b - n;
  if (tmp > 0) res -= tmp * tmp;
  return res;
}
int main() {
  long long c;
  int l, r, x;
  scanf("%d%d%d%I64d", &n, &a, &b, &c);
  l = 0;
  r = 2 * n;
  while (l != r) {
    x = l + r >> 1;
    if (cal(x) < c)
      l = x + 1;
    else
      r = x;
  }
  printf("%d\n", l);
}
