#include <bits/stdc++.h>
using namespace std;
struct hren {
  long int pos, ob, tim;
};
hren down, up, lin, rech, u1, u2, u3, u4;
long long int c, q = 1, f = 1, g = 1;
long int n, j, i, timer = 0, x, y, p = 0;
void pere1(hren &q) {
  if (timer == q.tim) {
    q.pos = 1;
    q.ob = 1;
    return;
  }
  if (timer > q.tim) {
    q.pos += 2;
    q.ob += q.pos;
    return;
  }
}
void pere2(hren &q) {
  if (timer == q.tim) {
    q.pos = 1;
    q.ob = 1;
    return;
  }
  if (timer > q.tim) {
    q.pos += 1;
    q.ob += q.pos;
    return;
  }
}
void plusq(hren r) {
  if (r.ob > 0) q += r.ob;
  return;
}
void minusq(hren r) {
  if (r.ob > 0) q -= r.ob;
  return;
}
int main() {
  scanf("%d%d%d%I64d", &n, &x, &y, &c);
  down.tim = x;
  up.tim = n - x + 1;
  rech.tim = y;
  lin.tim = n - y + 1;
  u1.tim = n - y + x + 1;
  u3.tim = n - x + y + 1;
  u2.tim = x + y;
  u4.tim = 2 * n + 2 - x - y;
  while (1) {
    if (g >= c) {
      printf("%d", timer);
      return 0;
    }
    timer++;
    pere1(up);
    pere1(down);
    pere1(lin);
    pere1(rech);
    pere2(u1);
    pere2(u2);
    pere2(u3);
    pere2(u4);
    p += 4;
    f += p;
    q = 0;
    plusq(up);
    plusq(down);
    plusq(lin);
    plusq(rech);
    minusq(u1);
    minusq(u2);
    minusq(u3);
    minusq(u4);
    g = f - q;
  }
  return 0;
}
