#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
long long sqr(long long t) {
  if (t <= 0) return 0;
  return t * t;
}
long long tri(long long t) {
  if (t <= 0) return 0;
  return t * (t + 1) / 2;
}
long long Get_ans(long long t) {
  long long f = sqr(t) + sqr(t + 1);
  long long g =
      sqr(y + t - n) + sqr(x + t - n) + sqr(t - x + 1) + sqr(t - y + 1);
  long long h = tri(t - 2 * n + x + y - 1) + tri(t - x - y + 1) +
                tri(t - n - x + y) + tri(t - n + x - y);
  return f - g + h;
}
int main() {
  cin >> n >> x >> y >> c;
  long long l = 0, r = c, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (Get_ans(mid) < c)
      l = mid + 1;
    else
      r = mid - 1;
  }
  if (Get_ans(r) >= c)
    cout << r << '\n';
  else if (Get_ans(mid) >= c)
    cout << mid << '\n';
  else if (Get_ans(l) >= c)
    cout << l << '\n';
  return 0;
}
