#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double PI = 3.141592653589793116, EPS = 1e-9,
                  GOLD = ((1 + sqrt(5)) / 2);
template <class T>
int getbit(T s, int i) {
  return (s >> 1) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
long long n, x, y, c;
long long diagSqr(long long z) { return (2 * z * (z + 1) + 1); }
long long diagTri(long long z) { return (z * z); }
long long sqrTri(long long z) {
  if (z < 0) return 0;
  return ((z + 1) * z / 2);
}
void VarInput() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> x >> y >> c;
}
void ProSolve() {
  long long top = 0, bot = 3 * n;
  while (top != bot) {
    long long mid = (top + bot) / 2;
    long long total = diagSqr(mid);
    long long u = max(0LL, mid - x + 1), d = max(0LL, mid - (n - x));
    long long l = max(0LL, mid - y + 1), r = max(0LL, mid - (n - y));
    total -= diagTri(u);
    total -= diagTri(d);
    total -= diagTri(l);
    total -= diagTri(r);
    total += sqrTri(mid - (x + y) + 1);
    total += sqrTri(mid - (x + n - 1 - y) - 1);
    total += sqrTri(mid - (n - 1 - x + y) - 1);
    total += sqrTri(mid - (n - 1 - x + n - 1 - y) - 3);
    if (total < c)
      top = mid + 1;
    else
      bot = mid;
  }
  cout << top;
}
int main() {
  VarInput();
  ProSolve();
  return 0;
}
