#include <bits/stdc++.h>
using namespace std;
int main() {
  int now = 1, tt = 0, n, x, y, c;
  scanf("%d%d%d%d", &n, &x, &y, &c);
  while (now < c) {
    tt++;
    int l = min(x - 1, tt);
    now += max(l - max((y + tt - n), 0) + 1, 0) +
           max(l - max((tt - y + 1), 0) + 1, 0) - (l == tt);
    l = min(n - x, tt);
    now += max(l - max((y + tt - n), 1) + 1, 0) +
           max(l - max((tt - y + 1), 1) + 1, 0) - (l == tt);
  }
  printf("%d\n", tt);
  return 0;
}
