#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x * neg;
}
inline void print(long long x) {
  if (x < 0) {
    putchar('-');
    print(abs(x));
    return;
  }
  if (x <= 9)
    putchar(x + '0');
  else {
    print(x / 10);
    putchar(x % 10 + '0');
  }
}
long long n = read(), x = read(), y = read(), t = read();
inline long long calc(long long s) {
  if (s <= 0) return 0;
  return 1ll * (s + 1) * s / 2;
}
inline bool check(long long s) {
  long long a = x - 1, b = y - 1, c = n - x, d = n - y;
  long long ans = min(s, a) + min(s, b) + min(s, c) + min(s, d) + 1;
  s--;
  ans += calc(s) * 4 - 2 * calc(s - a) - 2 * calc(s - b) - 2 * calc(s - c) -
         2 * calc(s - d);
  ans += calc(s - a - b) + calc(s - b - c) + calc(s - c - d) + calc(s - d - a);
  return ans >= t;
}
signed main() {
  long long l = 0, r = INT_MAX, ans = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  print(ans);
  return 0;
}
