#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > matmul(vector<vector<long long> > &a,
                                  vector<vector<long long> > &b) {
  int i, j, k, n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      long long temp = 0;
      for (k = 0; k < n; k++)
        temp = (temp + a[i][k] * b[k][j]) % (1000000007LL);
      ans[i][j] = temp;
    }
  return ans;
}
vector<vector<long long> > matpwr(vector<vector<long long> > &a, long long p) {
  int n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (int i = 0; i < n; i++) ans[i][i] = 1;
  while (p) {
    if (p & 1) ans = matmul(ans, a);
    a = matmul(a, a);
    p >>= 1;
  }
  return ans;
}
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long invMod(long long n, long long mod = (1000000007LL)) {
  return pwr(n, mod - 2, mod);
}
long long n, x, y, c;
vector<pair<long long, int> > multiply(const vector<pair<long long, int> > &a,
                                       const vector<pair<long long, int> > &b) {
  vector<pair<long long, int> > ans;
  for (int i = 0; i < (int)a.size(); i++)
    for (int j = 0; j < (int)b.size(); j++) {
      long long newpower = a[i].second + b[j].second;
      long long coeff = a[i].first * b[j].first;
      bool found = false;
      for (int k = 0; k < (int)ans.size(); k++)
        if (ans[k].second == newpower) {
          found = true;
          ans[k].first += coeff;
          break;
        }
      if (!found) ans.push_back(pair<long long, int>(coeff, newpower));
    }
  return ans;
}
long long countSolutions(long long alo, long long ahi, long long blo,
                         long long bhi, long long clo, long long chi,
                         long long rhs) {
  if (alo > ahi || blo > bhi || clo > chi) return 0;
  vector<pair<long long, int> > a, b, c;
  a.push_back(pair<long long, int>(1, alo));
  a.push_back(pair<long long, int>(-1, ahi + 1));
  b.push_back(pair<long long, int>(1, blo));
  b.push_back(pair<long long, int>(-1, bhi + 1));
  c.push_back(pair<long long, int>(1, clo));
  c.push_back(pair<long long, int>(-1, chi + 1));
  a = multiply(a, b);
  a = multiply(a, c);
  long long ans = 0;
  for (int i = 0; i < (int)a.size(); i++) {
    long long havePower = a[i].second;
    long long needPower = rhs - havePower;
    if (needPower < 0) continue;
    ans += a[i].first * ((needPower + 2) * (needPower + 1)) / 2LL;
  }
  return ans;
}
long long affectedSquares(long long offset) {
  offset--;
  long long xmin = min(offset, x - 1);
  long long xmax = min(offset, n - x);
  long long ymin = min(offset, y - 1);
  long long ymax = min(offset, n - y);
  long long ans = 0;
  ans += ymax + ymin + 1;
  ans += xmax + xmin;
  ans += countSolutions(1, xmax, 1, ymax, 0, offset, offset);
  ans += countSolutions(1, xmax, 1, ymin, 0, offset, offset);
  ans += countSolutions(1, xmin, 1, ymax, 0, offset, offset);
  ans += countSolutions(1, xmin, 1, ymin, 0, offset, offset);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> x >> y >> c;
  long long lo = 1, hi = c;
  long long ans = hi;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (affectedSquares(mid) >= c) {
      ans = min(ans, mid);
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  cout << ans - 1;
  return 0;
}
