#include <bits/stdc++.h>
using namespace std;
long long sum(long long n) { return n * (n + 1) / 2; }
long long n, x, y, c;
long long cal(long long k) {
  long long o = 1 + 4 * sum(k);
  long long l = 0, r = 0;
  if (y + k > n) {
    o -= (y + k - n) * (y + k - n);
    r = (y + k - n);
  }
  if (y - k < 1) {
    o -= (1 - (y - k)) * (1 - (y - k));
    l = (1 - (y - k));
  }
  if (x - k < 1) {
    long long L = max(l - (x - 1), 1LL), R = max(r - (x - 1), 1LL);
    long long top = 1 - (x - k);
    o -= sum(top) - sum(L - 1) + sum(top) - sum(R - 1) - top;
  }
  if (x + k > n) {
    long long L = max(l - (n - x), 1LL), R = max(r - (n - x), 1LL);
    long long top = (x + k) - n;
    o -= sum(top) - sum(L - 1) + sum(top) - sum(R - 1) - top;
  }
  return o;
}
int main() {
  cin >> n >> x >> y >> c;
  long long l = 0, r = 10000000, o = -1;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (cal(mid) >= c)
      o = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << o << endl;
  return 0;
}
