#include <bits/stdc++.h>
using namespace std;
long long s1(long long n) { return n <= 0 ? 0 : n * n; }
long long s2(long long n) { return n <= 0 ? 0 : n * (n + 1) / 2; }
int main() {
  long long n, x, y, c;
  cin >> n >> x >> y >> c;
  long long l = 0, r = 2 * n;
  while (l != r) {
    long long m = (l + r) / 2;
    long long now = s1(m) + s1(m + 1);
    now -= s1(x + m - n);
    now -= s1(m - x + 1);
    now -= s1(y + m - n);
    now -= s1(m - y + 1);
    now += s2(m - (n - x + n - y) - 1);
    now += s2(m - (n - x + y - 1) - 1);
    now += s2(m - (x - 1 + n - y) - 1);
    now += s2(m - (x - 1 + y - 1) - 1);
    if (now >= c)
      r = m;
    else
      l = m + 1;
  }
  cout << l << endl;
  return 0;
}
