#include <bits/stdc++.h>
using namespace std;
long long n, x, y, m;
long long cul(long long p) {
  if (p <= 0) return 0;
  return (p + 1) * p / 2;
}
int judge(long long p) {
  long long a = x - 1, b = y - 1, c = n - x, d = n - y;
  long long ans = min(p, a) + min(p, b) + min(p, c) + min(p, d) + 1;
  p--;
  ans += cul(p) * 4 - 2 * cul(p - a) - 2 * cul(p - b) - 2 * cul(p - c) -
         2 * cul(p - d);
  ans += cul(p - a - b) + cul(p - b - c) + cul(p - c - d) + cul(p - d - a);
  return ans >= m;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &x, &y, &m);
  long long l = 0, r = 1e9, ans = 0;
  while (l <= r) {
    long long mid = (r + l) >> 1;
    if (judge(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
