#include <bits/stdc++.h>
using namespace std;
long long n, i0_, j0_, c;
long long ap(long long L, long long R) {
  if (R < 0 || L < 0 || L > R) return 0;
  long long res = (R * (R + 1)) / 2 - (L * (L - 1)) / 2;
  return res < 0 ? 0 : res;
}
long long aps(long long L, long long R) { return ap(1, R - L + 1); }
long long mabs(long long q) { return q < 0 ? -q : q; }
long long countDiagonal(long long i, long long j, long long n, long long t) {
  return ap(i + j, t);
}
long long countTriangle(long long i, long long j, long long n, long long t) {
  return aps(j + 1, min(i + j - 1, t));
}
long long countTriangles(long long i, long long j, long long n, long long t) {
  return countTriangle(i, j, n, t) + countTriangle(j, i, n, t);
}
long long countSegment(long long i, long long j, long long n, long long t) {
  return countTriangles(i, j, n, t) + countDiagonal(i, j, n, t);
}
void rot(long long &i, long long &j, long long n) {
  long long ik = n - j + 1, jk = i;
  i = ik;
  j = jk;
}
long long doubleCells(long long i, long long j, long long n, long long t) {
  return max(-(i - (t)), 0ll) + max(-(j - (t)), 0ll) +
         max(i + (t - 1) - n, 0ll) + max(j + (t - 1) - n, 0ll);
}
long long get(long long i, long long j, long long n, long long t) {
  long long res = 0;
  res += 2 * t * (t - 1) + 1;
  res += doubleCells(i, j, n, t);
  for (int q = 0; q < 4; q++) {
    res -= countSegment(i, j, n, t);
    rot(i, j, n);
  }
  return res;
}
long long binarySearch() {
  long long L = 0;
  long long R = 1000000100ll;
  while (R - L > 1) {
    long long M = (L + R) / 2;
    if (get(i0_, j0_, n, M) >= c)
      R = M;
    else
      L = M;
  }
  return R;
}
int main() {
  cin >> n >> i0_ >> j0_ >> c;
  cout << binarySearch() - 1 << endl;
  return 0;
}
