#include <bits/stdc++.h>
using namespace std;
long long border[4];
long long corner[4];
long long square(long long n) { return n * n; }
int main() {
  long long n, x, y, c;
  cin >> n >> x >> y >> c;
  border[0] = n - x + 1;
  border[1] = n + 1 - border[0];
  border[2] = n - y + 1;
  border[3] = n + 1 - border[2];
  corner[0] = border[3] + border[1];
  corner[1] = border[3] + border[0];
  corner[2] = border[2] + border[1];
  corner[3] = border[2] + border[0];
  if (c == 1) {
    cout << "0" << endl;
    return 0;
  }
  long long at_most =
      max(max(corner[0], corner[1]), max(corner[2], corner[3])) + 2;
  long long at_least = 0;
  while (at_most - 1 > at_least) {
    long long guess = (at_most + at_least) / 2;
    long long total = 1 + 2 * guess * (guess + 1);
    for (int i = 0; i < 4; i++) {
      if (guess >= border[i]) total -= square(guess - border[i] + 1);
    }
    for (int i = 0; i < 4; i++) {
      if (guess >= corner[i])
        total += (square(guess - corner[i] + 1) + guess - corner[i] + 1) / 2;
    }
    if (total >= c)
      at_most = guess;
    else
      at_least = guess;
  }
  cout << at_most << endl;
  return 0;
}
