#include <bits/stdc++.h>
const int INF = 0x7f7f7f7f;
using namespace std;
long long n, x, y, c;
bool check(long long p) {
  long long cnt = p * p + (p + 1) * (p + 1);
  long long up = p - x, dn = p + x - n + 1, le = p - y, ri = p + y - n + 1,
            curc = 0, curl = 0;
  if (up > 0) curc += up * up;
  if (dn > 0) curc += dn * dn;
  if (le > 0) curl += le * le;
  if (ri > 0) curl += ri * ri;
  long long cur = curl + curc;
  if (up + ri - p - 1 > 0) cur -= (up + ri - p) * (up + ri - p - 1) / 2;
  if (dn + ri - p - 1 > 0) cur -= (dn + ri - p) * (dn + ri - p - 1) / 2;
  if (dn + le - p - 1 > 0) cur -= (dn + le - p) * (dn + le - p - 1) / 2;
  if (up + le - p - 1 > 0) cur -= (up + le - p) * (up + le - p - 1) / 2;
  return cnt - cur >= c;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &x, &y, &c);
  x--, y--;
  long long l = 0, r = 1e9 + 5;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", l);
  return 0;
}
