#include <bits/stdc++.h>
using namespace std;
long long n, x, y, m;
long long u, d, l, r;
bool can(long long t) {
  long long sum = t * (t + 1) * 2 + 1;
  if (t > l) sum -= (t - l) * (t - l);
  if (t > r) sum -= (t - r) * (t - r);
  if (t > u) sum -= (t - u) * (t - u);
  if (t > d) sum -= (t - d) * (t - d);
  long long z = 0;
  if (t > l + d) z = (t - l - d - 1) * (t - l - d) / 2, sum += z;
  if (t > r + d) z = (t - r - d - 1) * (t - d - r) / 2, sum += z;
  if (t > l + u) z = (t - l - u - 1) * (t - l - u) / 2, sum += z;
  if (t > u + r) z = (t - r - u - 1) * (t - u - r) / 2, sum += z;
  if (sum >= m) return true;
  return false;
}
int main() {
  cin >> n >> x >> y >> m;
  l = x - 1, u = y - 1, r = n - x, d = n - y;
  long long L = 0, R = 3 * n;
  while (L <= R) {
    long long M = (L + R) >> 1;
    if (can(M))
      R = M - 1;
    else
      L = M + 1;
  }
  cout << L << endl;
}
