#include <bits/stdc++.h>
using namespace std;
long long abs2(long long x) {
  if (x < 0) return -x;
  return 0;
}
long long getPyram(long long x, long long n, long long on_left,
                   long long on_ryt) {
  long long res = x;
  long long t1 = min(on_ryt - 1, x - 1);
  long long t2 = min(on_left - 1, x - 1);
  long long left = (t1 * (t1 + 1)) / 2 + (on_ryt - 1) * abs2(on_ryt - x);
  long long right = (t2 * (t2 + 1)) / 2 + (on_left - 1) * abs2(on_left - x);
  res += (left + right);
  return res;
}
long long getPyram2(long long x, long long n, long long on_left,
                    long long on_ryt) {
  long long res = x * x;
  return res;
}
long long solve(long long x, long long y, long long n, long long tim) {
  tim++;
  long long best = tim * tim + (tim - 1) * (tim - 1);
  long long on_right = n - x + 1;
  long long on_left = x;
  long long on_up = y;
  long long on_down = n - y + 1;
  long long cut_right = on_right - tim;
  if (cut_right < 0) {
    cut_right *= -1;
    best -= getPyram2(cut_right, n, on_up, on_down);
  }
  long long cut_left = on_left - tim;
  if (cut_left < 0) {
    cut_left *= -1;
    best -= getPyram2(cut_left, n, on_up, on_down);
  }
  long long cut_up = on_up - tim;
  if (cut_up < 0) {
    cut_up *= -1;
    best -= getPyram(cut_up, n, on_left, on_right);
  }
  long long cut_down = on_down - tim;
  if (cut_down < 0) {
    cut_down *= -1;
    best -= getPyram(cut_down, n, on_left, on_right);
  }
  if (best < 0) best = LLONG_MAX;
  return best;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long x;
  cin >> x;
  long long y;
  cin >> y;
  long long c;
  cin >> c;
  long long l = 0;
  long long r = 4 * n;
  long long res = LLONG_MAX;
  while (l <= r) {
    if (l == r) {
      if (solve(y, x, n, l) >= c) {
        res = min(res, l);
      }
      break;
    }
    long long m = (l + r) / 2;
    if (solve(y, x, n, m) >= c) {
      res = min(res, m);
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  cout << res << '\n';
  return 0;
}
