#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
long long find(long long t) {
  long long base = 1 + 2 * t * (t + 1);
  if (x + t > n) base -= (x + t - n) * (x + t - n);
  if (x - t < 1) base -= (x - t - 1) * (x - t - 1);
  if (y + t > n) base -= (y + t - n) * (y + t - n);
  if (y - t < 1) base -= (y - t - 1) * (y - t - 1);
  if (t > (n - x) + (n - y) + 1) {
    long long tmp = t - ((n - x) + (n - y) + 1);
    base += tmp * (tmp + 1) / 2;
  }
  if (t > (x - 1) + (n - y) + 1) {
    long long tmp = t - ((x - 1) + (n - y) + 1);
    base += tmp * (tmp + 1) / 2;
  }
  if (t > (x - 1) + (y - 1) + 1) {
    long long tmp = t - ((x - 1) + (y - 1) + 1);
    base += tmp * (tmp + 1) / 2;
  }
  if (t > (n - x) + (y - 1) + 1) {
    long long tmp = t - ((n - x) + (y - 1) + 1);
    base += tmp * (tmp + 1) / 2;
  }
  return base;
}
long long binsearch(long long s, long long e) {
  if (e < s) return -1;
  if (e == s) return s;
  if (s + 1 == e) {
    if (find(s) >= c) return s;
    return e;
  }
  long long mid = (s + e) / 2;
  if (find(mid) >= c)
    return binsearch(s, mid);
  else
    return binsearch(mid + 1, e);
}
int main() {
  cin >> n >> x >> y >> c;
  cout << binsearch(0, 2 * n) << '\n';
}
