#include <bits/stdc++.h>
using namespace std;
const long long maxAns = 2000000000;
long long x, y, n, c, t1, t2, t3, t4;
long long mk2(long long x) {
  if (x <= 0) return 0;
  return ((x + 1) * x) / 2;
}
long long mk(long long x) {
  if (x <= 0) return 0;
  return x * x;
}
long long count(long long time) {
  long long ans = mk(time - t1) + mk(time - t2) + mk(time - t3) +
                  mk(time - t4) - mk2(time - (t1 + t2 + 1)) -
                  mk2(time - (t2 + t3 + 1)) - mk2(time - (t3 + t4 + 1)) -
                  mk2(time - (t4 + t1 + 1));
  ans = ((time + 1) * (time)) * 2 + 1 - ans;
  return ans;
}
long long bin(long long l, long long r) {
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (count(m) < c)
      l = m;
    else
      r = m;
  }
  return r;
}
int main() {
  cin >> n >> x >> y >> c;
  if (c == 1) {
    cout << 0;
    return 0;
  }
  t1 = x - 1;
  t2 = n - y;
  t3 = n - x;
  t4 = y - 1;
  cout << bin(0, maxAns);
  return 0;
}
