#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, y, c, l = 0, r = 2000000000, m, s;
  cin >> n >> x >> y >> c;
  while (l < r) {
    m = l + (r - l) / 2;
    s = 2 * m * (m + 1) + 1;
    s -= max(0ll, x + m - n) * max(0ll, x + m - n);
    s -= max(0ll, y + m - n) * max(0ll, y + m - n);
    s -= max(0ll, m - x + 1) * max(0ll, m - x + 1);
    s -= max(0ll, m - y + 1) * max(0ll, m - y + 1);
    s +=
        max(0ll, m + (x - n + y - n)) * (max(0ll, m + (x - n + y - n)) - 1) / 2;
    s +=
        max(0ll, m + (x - n - y + 1)) * (max(0ll, m + (x - n - y + 1)) - 1) / 2;
    s += max(0ll, m + (-x + 1 + y - n)) * (max(0ll, m + (-x + 1 + y - n)) - 1) /
         2;
    s += max(0ll, m + (-x + 1 - y + 1)) * (max(0ll, m + (-x + 1 - y + 1)) - 1) /
         2;
    if (s < c)
      l = m + 1;
    else
      r = m;
  }
  cout << r;
  return 0;
}
