#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
bool check(long long tm) {
  long long upr = max(0ll, x + tm - n), dwr = max(0ll, tm + 1 - x),
            ltr = max(0ll, tm + 1 - y), rtr = max(0ll, y + tm - n);
  long long ans = (tm + 1) * (tm + 1) + tm * tm;
  ans -= upr * upr;
  ans -= dwr * dwr;
  ans -= ltr * ltr;
  ans -= rtr * rtr;
  long long ru = max(0ll, tm - (2 * n + 1 - x - y)),
            ld = max(0ll, tm + 1 - x - y), lu = max(0ll, tm - (n - (x - y))),
            rd = max(0ll, tm - ((x - y) + n));
  ans += (ld + 1) * ld / 2;
  ans += (ru + 1) * ru / 2;
  ans += (lu + 1) * lu / 2;
  ans += (rd + 1) * rd / 2;
  return (ans >= c);
}
long long solve() {
  long long l = 0, r = 2 * n, m;
  while (l < r) {
    m = (l + r) / 2ll;
    if (check(m))
      r = m;
    else
      l = m + 1;
  }
  return l;
}
int main() {
  cin >> n >> x >> y >> c;
  cout << solve() << endl;
  return 0;
}
