#include <bits/stdc++.h>
using namespace std;
long long fn(long long x) {
  long long ret = (x * (x + 1)) / 2;
  if (x < 0) ret = 0;
  return ret;
}
long long fn(long long R, long long K1, long long K2) {
  long long ret = 0;
  K1 = min(K1, R - 1);
  K2 = min(K2, R);
  if (R - K1 >= K2) return ((K1 + 1) * K2);
  ret -= fn(R - K1 - 1);
  ret += fn(K2);
  ret += (R - K2) * K2;
  return ret;
}
long long N, X, Y, C;
long long bin(long long start, long long end) {
  if (start > end) return start;
  long long mid = (start + end) / 2;
  long long ret = 1, foo = 0;
  foo = fn(mid, N - X, N - Y);
  ret += foo;
  foo = fn(mid, N - Y, X - 1);
  ret += foo;
  foo = fn(mid, X - 1, Y - 1);
  ret += foo;
  foo = fn(mid, Y - 1, N - X);
  ret += foo;
  if (ret >= C)
    return bin(start, mid - 1);
  else
    return bin(mid + 1, end);
}
inline void ReadInput(void) {
  scanf("%lld", &N);
  scanf("%lld", &X);
  scanf("%lld", &Y);
  scanf("%lld", &C);
}
inline void solve(void) {
  if (C == 1)
    cout << 0 << endl;
  else
    cout << bin(1, 2 * N) << endl;
}
inline void Refresh(void) {}
int main() {
  ReadInput();
  solve();
  return 0;
}
