#include <bits/stdc++.h>
using namespace std;
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
inline double nf() {
  double a;
  scanf("%lf", &a);
  return a;
}
template <class T>
void out(T a, T b) {
  bool first = true;
  for (T i = a; i != b; i++) {
    if (!first) printf(" ");
    first = false;
    cout << *i;
  }
  puts("");
}
template <class T>
void outl(T a, T b) {
  for (T i = a; i != b; i++) cout << *i << "\n";
}
int n, x, y, c;
int cur;
int ans = 0;
int l, r, t, d;
int lx, ly, rx, ry, dx, dy, tx, ty;
int fx, fy, gx, gy;
inline bool ok(int qq) { return 1 <= qq && qq <= n; }
int main() {
  scanf("%d %d %d %d", &n, &x, &y, &c);
  cur = 1;
  while (cur < c) {
    ans++;
    l = x - ans;
    r = x + ans;
    t = y + ans;
    d = y - ans;
    lx = l, ly = y, rx = r, ry = y, dx = x, dy = d, tx = x, ty = t;
    fx = dx, fy = dy, gx = rx, gy = ry;
    if (fy <= 0) {
      int add = 1 - fy;
      fx += add;
      fy += add;
    }
    if (gx > n) {
      int add = gx - n;
      gx -= add;
      gy -= add;
    }
    if (ok(fx) && ok(fy) && ok(gx) && ok(gy)) cur += max(gx - fx + 1, 0);
    fx = dx, fy = dy, gx = lx, gy = ly;
    if (fy <= 0) {
      int add = 1 - fy;
      fx -= add;
      fy += add;
    }
    if (gx <= 0) {
      int add = 1 - gx;
      gx += add;
      gy -= add;
    }
    if (ok(fx) && ok(fy) && ok(gx) && ok(gy)) cur += max(fx - gx + 1, 0);
    fx = tx, fy = ty, gx = rx, gy = ry;
    if (fy > n) {
      int add = fy - n;
      fx += add;
      fy -= add;
    }
    if (gx > n) {
      int add = gx - n;
      gx -= add;
      gy += add;
    }
    if (ok(fx) && ok(fy) && ok(gx) && ok(gy)) cur += max(gx - fx + 1, 0);
    fx = tx, fy = ty, gx = lx, gy = ly;
    if (fy > n) {
      int add = fy - n;
      fx -= add;
      fy -= add;
    }
    if (gx <= 0) {
      int add = 1 - gx;
      gx += add;
      gy += add;
    }
    if (ok(fx) && ok(fy) && ok(gx) && ok(gy)) cur += max(fx - gx + 1, 0);
    if (ok(lx) && ok(ly)) cur--;
    if (ok(rx) && ok(ry)) cur--;
    if (ok(dx) && ok(dy)) cur--;
    if (ok(tx) && ok(ty)) cur--;
  }
  printf("%d\n", ans);
}
