#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
bool check(long long T) {
  long long res = T * T + (T + 1) * (T + 1);
  if (T + x >= n) res -= (T - (n - x - 1)) * (T - (n - x - 1));
  if (T + y >= n) res -= (T - (n - y - 1)) * (T - (n - y - 1));
  if (x - T < 0) res -= (T - x) * (T - x);
  if (y - T < 0) res -= (T - y) * (T - y);
  if (n - x + n - y <= T) {
    long long t = T - (n - x + n - y) + 1;
    res += t * (t + 1) / 2;
  }
  if (n - x + y + 1 <= T) {
    long long t = T - (n - x + y + 1) + 1;
    res += t * (t + 1) / 2;
  }
  if (x + 1 + n - y <= T) {
    long long t = T - (n - y + x + 1) + 1;
    res += t * (t + 1) / 2;
  }
  if (x + 1 + y + 1 <= T) {
    long long t = T - (x + 1 + y + 1) + 1;
    res += t * (t + 1) / 2;
  }
  return res >= c;
}
int main() {
  cin >> n >> x >> y >> c;
  --x, --y;
  long long lo = 0, hi = 4 * n;
  while (lo < hi) {
    long long mid = lo + (hi - lo) / 2;
    if (check(mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  cout << hi << endl;
  return 0;
}
