#include <bits/stdc++.h>
using namespace std;
int n, x, y, c;
long long count(int z, int x, int y) {
  long long ans = z;
  ans = ans * (ans + 1);
  ans /= 2;
  long long rast = max(z - y, 0);
  rast = rast * (rast + 1);
  rast /= 2;
  long long top = max(z - x, 0);
  top = top * (top + 1);
  top /= 2;
  long long esh = max(0, z - x - y);
  esh = esh * (esh + 1);
  esh /= 2;
  return ans - rast - top + esh;
}
long long line(int z, int x) {
  long long ans = min(z, x);
  return ans;
}
bool happy(int z) {
  z++;
  return count(z, x, y) + count(z, n - x + 1, y) + count(z, x, n - y + 1) +
             count(z, n - x + 1, n - y + 1) - line(z, x) - line(z, n - x + 1) -
             line(z, y) - line(z, n - y + 1) + 1 >=
         c;
}
int binary() {
  int p = 0, q = 2 * n;
  while (p < q) {
    int r = p + q;
    r /= 2;
    if (happy(r))
      q = r;
    else
      p = r + 1;
  }
  return p;
}
int main() {
  cin >> n >> x >> y >> c;
  cout << binary() << endl;
}
