#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double PI = acos(-1);
const double EPS = 1e-8;
long long func(int i) { return i * i; }
long long func_d(int i) { return func(i) / 2; }
int main() {
  long long n, x, y, c;
  cin >> n >> x >> y >> c;
  x--;
  y--;
  long long low = -1, high = 1LL << 31;
  while (low + 1 < high) {
    long long mid = (low + high) / 2;
    long long sum = 2 * mid * (mid + 1) + 1;
    long long a[4] = {mid - x, mid - y, mid - (n - 1 - x), mid - (n - 1 - y)};
    long long b[4] = {y, n - 1 - x, n - 1 - y, x};
    for (int i = 0; i < (int)4; ++i) {
      if (a[i] <= 0) continue;
      sum -= a[i] * a[i];
      int j = (i + 1) % 4;
      long long s = (a[i] - b[i]);
      if (s >= 0) sum += s * (s - 1) / 2;
    }
    if (sum >= c)
      high = mid;
    else
      low = mid;
  }
  cout << high << endl;
}
