#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
using namespace std;
long long n, m, x, y, c, tr[1005][1005];
long long mul(long long tx) { return tx * tx; }
long long cal(long long tn) { return ((tn + 1) * tn) / 2; }
bool check(long long t) {
  long long sum = t * t + (t + 1) * (t + 1);
  int l = x - 1, r = n - x, u = y - 1, d = n - y;
  if (t > l) sum -= mul(t - l);
  if (t > r) sum -= mul(t - r);
  if (t > u) sum -= mul(t - u);
  if (t > d) sum -= mul(t - d);
  if (t > l + d) sum += cal(t - (l + d) - 1);
  if (t > l + u) sum += cal(t - (l + u) - 1);
  if (t > r + d) sum += cal(t - (r + d) - 1);
  if (t > r + u) sum += cal(t - (r + u) - 1);
  if (sum >= c) return 1;
  return 0;
}
int main() {
  cin >> n >> x >> y >> c;
  if (c == 1) {
    cout << 0;
    return 0;
  }
  if (c <= 5) {
    cout << 1;
    return 0;
  }
  int l = 0, r = 2 * n;
  while (r >= l) {
    int mid = (r + l) >> 1;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << l << endl;
}
