#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= fh;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
long long n, x, y, c;
bool check(long long mid) {
  long long ans = 2 * mid * mid + 2 * mid + 1;
  if (x - mid < 1) ans -= (mid - x + 1) * (mid - x + 1);
  if (x + mid > n) ans -= (x + mid - n) * (x + mid - n);
  if (y - mid < 1) ans -= (mid - y + 1) * (mid - y + 1);
  if (y + mid > n) ans -= (y + mid - n) * (y + mid - n);
  if (mid - (x + y) + 1 >= 1)
    ans += (1 + mid - (x + y) + 1) * (mid - (x + y) + 1) / 2;
  if (mid - (x + n + 1 - y) + 1 >= 1)
    ans += (1 + mid - (x + n + 1 - y) + 1) * (mid - (x + n + 1 - y) + 1) / 2;
  if (mid - (n + 1 - x + y) + 1 >= 1)
    ans += (1 + mid - (n + 1 - x + y) + 1) * (mid - (n + 1 - x + y) + 1) / 2;
  if (mid - (n + 1 - x + n + 1 - y) + 1 >= 1)
    ans += (1 + mid - (n + 1 - x + n + 1 - y) + 1) *
           (mid - (n + 1 - x + n + 1 - y) + 1) / 2;
  return ans >= c;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x >> y >> c;
  long long l = 0, r = 1000000;
  while (l < r) {
    long long mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
