#include <bits/stdc++.h>
using namespace std;
long long ile(int a, int b, int l) {
  if (l <= 0) {
    return 0LL;
  }
  if (a > b) {
    swap(a, b);
  }
  long long res = 0;
  if (l <= a) {
    res = (long long)l * (l + 1) / 2;
  } else {
    res = (long long)a * (a + 1) / 2;
    l -= a;
    if (l <= b - a) {
      res += (long long)l * a;
    } else {
      res += (long long)(b - a) * a;
      l -= b - a;
      if (l <= a - 1) {
        res += (long long)a * l - (long long)l * (l + 1) / 2;
      } else {
        res += (long long)a * (a - 1) / 2;
        assert(res == (long long)a * b);
      }
    }
  }
  return res;
}
long long comp(int n, int x, int y, int r) {
  return ile(x, y, r + 1) + ile(n - x, y, r) + ile(x, n - y, r) +
         ile(n - x, n - y, r - 1);
}
int main(void) {
  int n, x, y, c;
  scanf("%d%d%d%d", &n, &x, &y, &c);
  int l = 0, r = 2 * n, res = 2 * n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (comp(n, x, y, mid) >= c) {
      res = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  printf("%d\n", res);
  return 0;
}
