#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x1, y1, x2, y2, dx1, dy1, dx2, dy2;
} Line;
typedef Line Lines[4];
int inSquare(int n, Line l) {
  int dx1 = max(l.x1 < 0 ? -l.x1 : 0, l.x1 >= n ? l.x1 - n + 1 : 0);
  int dy1 = max(l.y1 < 0 ? -l.y1 : 0, l.y1 >= n ? l.y1 - n + 1 : 0);
  int dx2 = max(l.x2 < 0 ? -l.x2 : 0, l.x2 >= n ? l.x2 - n + 1 : 0);
  int dy2 = max(l.y2 < 0 ? -l.y2 : 0, l.y2 >= n ? l.y2 - n + 1 : 0);
  int r = abs(l.x1 - l.x2) + 1 - max(dx1, dy1) - max(dx2, dy2);
  return r < 0 ? 0 : r;
}
int main() {
  int n, x, y, c;
  cin >> n >> x >> y >> c;
  x--;
  y--;
  Lines lines = {{x, y, x - 1, y - 1, 0, -1, 1, 0},
                 {x, y, x + 1, y - 1, 1, 0, 0, 1},
                 {x, y, x + 1, y + 1, 0, 1, -1, 0},
                 {x, y, x - 1, y + 1, -1, 0, 0, -1}};
  int t = 0;
  long long s = 1;
  while (s < c) {
    t++;
    for (int i = 0; i < 4; i++) {
      lines[i].x1 += lines[i].dx1;
      lines[i].y1 += lines[i].dy1;
      lines[i].x2 += lines[i].dx2;
      lines[i].y2 += lines[i].dy2;
      s += inSquare(n, lines[i]);
    }
  }
  cout << t << endl;
}
