#include <bits/stdc++.h>
using namespace std;
int n, x, y, s;
int a[5];
int flag = 0;
int fun(int x) { return x * (x + 1) / 2; }
int main() {
  cin >> n >> x >> y >> s;
  a[0] = x;
  a[1] = y;
  a[2] = n - x + 1;
  a[3] = n - y + 1;
  sort(a, a + 4);
  int x1 = a[0], x2 = a[1], x3 = a[2], x4 = a[3];
  int t = 1, tmp;
  while (t <= x1) {
    tmp = 2 * t * (t - 1) + 1;
    if (tmp >= s) {
      cout << t - 1 << endl;
      return 0;
    }
    t++;
  }
  while (t <= x2) {
    tmp = 2 * t * (t - 1) + 1 - (t - x1) * (t - x1);
    if (tmp >= s) {
      cout << t - 1 << endl;
      return 0;
    }
    t++;
  }
  while (t <= x3) {
    tmp = 2 * t * (t - 1) + 1 - (t - x1) * (t - x1) - (t - x2) * (t - x2);
    if (t <= x1 + x2) {
      tmp = tmp;
    } else {
      tmp += fun(t - x1 - x2);
    }
    if (tmp >= s) {
      cout << t - 1 << endl;
      return 0;
    }
    t++;
  }
  while (t <= x4) {
    tmp = 2 * t * (t - 1) + 1 - (t - x1) * (t - x1) - (t - x2) * (t - x2) -
          (t - x3) * (t - x3);
    if (t <= x1 + x2) {
      tmp = tmp;
    }
    if (t > x1 + x2 && t <= x1 + x3) {
      tmp += fun(t - x1 - x2);
    }
    if (t > x1 + x3) {
      tmp += fun(t - x1 - x2) + fun(t - x1 - x3);
    }
    if (tmp >= s) {
      cout << t - 1 << endl;
      return 0;
    }
    t++;
  }
  while (1) {
    tmp = 2 * t * (t - 1) + 1;
    tmp -= (t - x1) * (t - x1) + (t - x2) * (t - x2) + (t - x3) * (t - x3) +
           (t - x4) * (t - x4);
    if (t <= x1 + x2) {
      tmp = tmp;
    }
    if (t > x1 + x2 && t <= x1 + x3) {
      tmp += fun(t - x1 - x2);
    }
    if (t > x1 + x3 && t <= x2 + x4) {
      tmp += fun(t - x1 - x2) + fun(t - x1 - x3);
    }
    if (t > x2 + x4) {
      tmp += fun(t - x1 - x2) + fun(t - x1 - x3) + fun(t - x2 - x4);
    }
    if (tmp >= s) {
      cout << t - 1 << endl;
      return 0;
    }
    t++;
  }
  return 0;
}
