#include <bits/stdc++.h>
using namespace std;
long long n;
long long find(long long x, long long y, long long k) {
  long long xx = x - k - 1;
  long long yy = y + k;
  long long disx = abs(xx);
  long long disy = yy - n;
  if (xx >= 0 && yy <= n)
    return (k + 1) * (k + 2) / 2;
  else if (xx >= 0)
    return (k + 1) * (k + 2) / 2 - disy * (disy + 1) / 2;
  else if (yy <= n)
    return (k + 1) * (k + 2) / 2 - disx * (disx + 1) / 2;
  else {
    if (disx >= n - y + 1 && disy >= x) return (n - y + 1) * x;
    return (k + 1) * (k + 2) / 2 - disy * (disy + 1) / 2 -
           disx * (disx + 1) / 2;
  }
}
bool ok(long long k, long long x, long long y, long long c) {
  long long tot = find(x, y, k);
  tot += find(n - x + 1, y, k);
  tot += find(x, n - y + 1, k);
  tot += find(n - x + 1, n - y + 1, k);
  long long x1 = min(x - 1, k), x2 = min(n - x, k);
  long long y1 = min(y - 1, k), y2 = min(n - y, k);
  long long ret = tot - x1 - x2 - y1 - y2 - 3;
  return ret >= c;
}
int main() {
  long long x, y;
  long long c;
  cin >> n >> x >> y >> c;
  long long tmp = -1, tmp1 = c;
  while (tmp1 - tmp != 1) {
    long long m = (tmp1 + tmp) / 2;
    if (ok(m, x, y, c))
      tmp1 = m;
    else
      tmp = m;
  }
  cout << tmp1 << endl;
  return 0;
}
