#include <bits/stdc++.h>
using namespace std;
long long light = 0;
long long timep = 0;
long long add = 4;
long long ra = 1;
long long ba = 1;
long long ta = 1;
long long la = 1;
long long lta = 1;
long long rta = 1;
long long lba = 1;
long long rba = 1;
int main() {
  long long int x, y, n, c;
  cin >> n >> x >> y >> c;
  int lt = 0, rt = 0, lb = 0, rb = 0;
  long long int lx = x, rx = x, by = y, ty = y;
  light = 1;
  while (light < c) {
    light += add;
    add += 4;
    lx--;
    rx++;
    by++;
    ty--;
    if (ty <= 0) {
      light -= ta;
      ta += 2;
    }
    if (by > n) {
      light -= ba;
      ba += 2;
    }
    if (lx <= 0) {
      light -= la;
      la += 2;
    }
    if (rx > n) {
      light -= ra;
      ra += 2;
    }
    if (ty + x <= 0 || lx + y <= 0) lt = 1;
    if (n - x + ty < 0 || n - rx + 1 + y <= 0) rt = 1;
    if (n - by + 1 + x <= 0 || n - y + lx < 0) lb = 1;
    if (n - x + n - by + 1 < 0 || n - y + n - rx + 1 < 0) rb = 1;
    if (lt) {
      light += lta;
      lta++;
    }
    if (rt) {
      light += rta;
      rta++;
    }
    if (lb) {
      light += lba;
      lba++;
    }
    if (rb) {
      light += rba;
      rba++;
    }
    timep++;
  }
  cout << timep << endl;
}
