#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& o, pair<A, B>& p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "{";
  for (typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
    o << *it << ", ";
  return o << "}";
}
struct debugger {
  ostream& out;
  bool first;
  void start() { first = true; }
  debugger(ostream& out) : out(out) { start(); }
  void nl() {
    out << endl;
    start();
  }
  template <class T>
  debugger& operator,(T& v) {
    if (first)
      first = false;
    else
      out << ", ";
    out << v;
    return *this;
  }
  template <class T>
  debugger& operator,(pair<T*, int> arr) {
    out << "{";
    for (typeof((arr.second) - 1) i = (0); i <= ((arr.second) - 1); i++) {
      out << arr.first[i] << ", ";
    }
    out << "}";
    return *this;
  }
} dbg(cerr);
long long pyra(long long n) { return (n + 1) * (n + 1); }
long long incr(long long n) { return (n * (n + 1)) / 2; }
long long f(long long x, long long y, long long step, long long n) {
  long long ret = 2 * pyra(step) - (2 * step + 1);
  if (x + step > n) {
    ret -= pyra(x + step - n - 1);
  }
  if (y + step > n) {
    ret -= pyra(y + step - n - 1);
  }
  if (x - step < 1) {
    ret -= pyra(1 - (x - step) - 1);
  }
  if (y - step < 1) {
    ret -= pyra(1 - (y - step) - 1);
  }
  if (step - 1 - (n - x) - (n - y) > 0) {
    ret += incr(step - 1 - (n - x) - (n - y));
  }
  if (step - 1 - (n - x) - (y - 1) > 0) {
    ret += incr(step - 1 - (n - x) - (y - 1));
  }
  if (step - 1 - (x - 1) - (y - 1) > 0) {
    ret += incr(step - 1 - (x - 1) - (y - 1));
  }
  if (step - 1 - (x - 1) - (n - y) > 0) {
    ret += incr(step - 1 - (x - 1) - (n - y));
  }
  return ret;
}
int main() {
  long long n, x, y, c, lo, hi;
  cin >> n >> x >> y >> c;
  lo = 0;
  hi = 1e9 + 10;
  {}
  while (lo < hi) {
    long long mid = (lo + hi) / 2;
    if (f(x, y, mid, n) < c)
      lo = mid + 1;
    else
      hi = mid;
  }
  cout << lo << endl;
  return 0;
}
