#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int numOfPoints(long long int &x, long long int &y, long long int &n,
                          long long int t) {
  long long int region1 = 2 * t * (t + 1) + 1;
  long long int region2;
  if (y - t >= 1)
    region2 = 0;
  else
    region2 = abs(y - t - 1) * abs(y - t - 1);
  long long int region3;
  if (y + t <= n)
    region3 = 0;
  else
    region3 = abs(n - y - t) * abs(n - y - t);
  long long int region4;
  if (x - t >= 1)
    region4 = 0;
  else
    region4 = abs(x - t - 1) * abs(x - t - 1);
  long long int region5;
  if (x + t <= n)
    region5 = 0;
  else
    region5 = abs(n - x - t) * abs(n - x - t);
  long long int region6;
  if (t >= (n + 1 - y) + (n + 1 - x))
    region6 = (t - (n + 1 - y) - (n + 1 - x) + 1) *
              (t - (n + 1 - y) - (n + 1 - x) + 2) / 2;
  else
    region6 = 0;
  long long int region7;
  if (t >= (n + 1 - y) + (x - 0))
    region7 =
        (t - (n + 1 - y) - (x - 0) + 1) * (t - (n + 1 - y) - (x - 0) + 2) / 2;
  else
    region7 = 0;
  long long int region8;
  if (t >= (y - 0) + (n + 1 - x))
    region8 =
        (t - (y - 0) - (n + 1 - x) + 1) * (t - (y - 0) - (n + 1 - x) + 2) / 2;
  else
    region8 = 0;
  long long int region9;
  if (t >= (y - 0) + (x - 0))
    region9 = (t - (y - 0) - (x - 0) + 1) * (t - (y - 0) - (x - 0) + 2) / 2;
  else
    region9 = 0;
  return region1 - region2 - region3 - region4 - region5 + region6 + region7 +
         region8 + region9;
}
int main() {
  long long int i, j, k, l, m, n, p, q, x, y, z, a, b, c, r, fs, ls, md;
  scanf("%lld", &n);
  scanf("%lld", &x);
  scanf("%lld", &y);
  scanf("%lld", &c);
  if (c == 1) {
    printf("0\n");
    return 0;
  }
  fs = 0, ls = 2000000007LL;
  while (fs + 1 < ls) {
    md = (fs + ls) / 2;
    if (c <= numOfPoints(x, y, n, md))
      ls = md;
    else
      fs = md;
  }
  printf("%lld\n", ls);
  return 0;
}
