#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
long long get(long long d) {
  long long V[4] = {d - y, d - x, d - (n - 1 - x), d - (n - 1 - y)};
  long long U[4] = {d - (x + y + 1), d - (1 + (n - 1 - 0) - (x - y)),
                    d - (1 + (n - 1 - 0) - (y - x)),
                    d - (1 + (n - 1 + n - 1) - (x + y))};
  long long ans = d * d + (d + 1) * (d + 1);
  for (int i = 0; i < 4; i++) V[i] = max(V[i], 0LL), ans -= V[i] * V[i];
  for (int i = 0; i < 4; i++)
    U[i] = max(U[i], 0LL), ans += U[i] * (U[i] + 1) / 2;
  return ans;
}
long long get2(long long d) {
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cnt += (abs(i - x) + abs(j - y)) <= d;
  return cnt;
}
int main() {
  scanf(
      "%I64d"
      " "
      "%I64d"
      " "
      "%I64d"
      " "
      "%I64d",
      &n, &x, &y, &c);
  --x, --y;
  long long a = -1, b = 2e9 + 42;
  while (b - a > 1) {
    int m = (a + b) / 2;
    if (get(m) >= c)
      b = m;
    else
      a = m;
  }
  printf(
      "%I64d"
      "\n",
      b);
}
