#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
long long blocks(long long t) {
  long long res = 0;
  long long a1 = -1, a2 = 1, f = y, s = y;
  long long midu = x - t, midd = x + t, midl = y - t, midr = y + t;
  for (long long i = midu; i <= midd; i++) {
    if (i > 0 && i <= n) res += min(s, n) - max(1ll, f) + 1;
    if (f == midl) swap(a1, a2);
    f += a1, s += a2;
  }
  return res;
}
int main() {
  cin >> n >> x >> y >> c;
  long long l = 0, r = 1e5;
  while (r > l) {
    long long mid = (l + r) / 2;
    if (blocks(mid) >= c)
      r = mid;
    else
      l = mid + 1;
  }
  cout << r;
  return 0;
}
