#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
void print(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
long long n, c, x, y, res = 1, now = 1;
signed main() {
  n = read(), x = read(), y = read(), c = read();
  if (c == 1) {
    puts("0");
    return 0;
  }
  for (; c > res; now++) {
    long long L = min(now, y - 1);
    if (L == now) res--;
    res += max(0ll, L - max(now - x + 1, 1ll) + 1) +
           max(0ll, L - max(x + now - n, 1ll) + 1);
    long long R = min(now, n - y);
    if (R == now) res--;
    res += max(0ll, R - max(now - x + 1, 0ll) + 1) +
           max(0ll, R - max(x + now - n, 0ll) + 1);
  }
  printf("%lld\n", --now);
  return 0;
}
