#include <bits/stdc++.h>
using namespace std;
long long cal(long long s) {
  long long ret = (1LL + s) * s / 2;
  return 1LL + ret * 4LL;
}
long long cal2(long long s) {
  long long tm = (s * 2LL - 1LL);
  long long ret = (tm + 1) * s / 2LL;
  return ret;
}
long long cal3(long long s) {
  long long ret = (s + 1) * s / 2;
  return ret;
}
int main() {
  int n, x, y, c;
  scanf("%d%d%d%d", &n, &x, &y, &c);
  long long tmp = 1;
  int ans = 0;
  while (tmp < c) {
    ans++;
    int mid = ans;
    tmp = cal(mid);
    if (x + mid > n) tmp -= cal2(x + mid - n);
    if (x - mid < 1) tmp -= cal2(mid - x + 1);
    if (y + mid > n) tmp -= cal2(y + mid - n);
    if (y - mid < 1) tmp -= cal2(mid - y + 1);
    if (x + y <= mid) tmp += cal3(mid - (x + y) + 1);
    if (x + n + 1 - y <= mid) tmp += cal3(mid - (x + n + 1 - y) + 1);
    if (n + 1 - x + y <= mid) tmp += cal3(mid - (n + 1 - x + y) + 1);
    if (n + 1 - x + n + 1 - y <= mid)
      tmp += cal3(mid - (n + 1 - x + n + 1 - y) + 1);
  }
  printf("%d\n", ans);
}
