#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-7;
map<int, vector<int> > M;
int main() {
  int n, x, y, c;
  scanf("%d %d %d %d", &n, &x, &y, &c);
  int arrive_time[4] = {x + y, x + (n + 1 - y), y + (n + 1 - x),
                        (n + 1 - x) + (n + 1 - y)};
  for (int t = 0; true; t++) {
    int cell = 2 * t * t + 2 * t + 1;
    for (int dir = 0; dir < 4; dir++)
      if (t >= arrive_time[dir]) {
        int newt = t - arrive_time[dir] + 1;
        cell += newt * (newt + 1) / 2;
      }
    if (x <= t) {
      int newt = t - x + 1;
      cell -= newt * newt;
    }
    if (y <= t) {
      int newt = t - y + 1;
      cell -= newt * newt;
    }
    if (x >= n + 1 - t) {
      int newt = x - (n + 1 - t) + 1;
      cell -= newt * newt;
    }
    if (y >= n + 1 - t) {
      int newt = y - (n + 1 - t) + 1;
      cell -= newt * newt;
    }
    if (cell >= c) {
      printf("%d\n", t);
      break;
    }
  }
  return 0;
}
