#include <bits/stdc++.h>
using namespace std;
const int INF = 999999999;
const double EPSILON = 0.00000001;
int main() {
  long long n, x, y, c;
  cin >> n >> y >> x >> c;
  long long size = 1, dif = 4, h = 0, s = 1;
  long long x1 = x, x2 = n - x + 1, y1 = y, y2 = n - y + 1;
  while (s < c) {
    h++;
    s = size;
    long long y11 = 2 * (h - y1) - 1, y22 = 2 * (h - y2) - 1;
    y11 = (y11 / 2) + 1;
    y22 = (y22 / 2) + 1;
    if (h > y1) {
      s -= 1LL * (h - y1) * (h - y1);
    }
    if (h > y2) {
      s -= 1LL * (h - y2) * (h - y2);
    }
    if (h > x1) {
      s -= 1LL * (h - x1) * (h - x1);
    }
    if (h > x2) {
      s -= 1LL * (h - x2) * (h - x2);
    }
    if (y11 > x2) {
      long long b = y11 - x2;
      s += b * (b + 1) / 2;
    }
    if (y11 > x1) {
      long long b = y11 - x1;
      s += b * (b + 1) / 2;
    }
    if (y22 > x1) {
      long long b = y22 - x1;
      s += b * (b + 1) / 2;
    }
    if (y22 > x2) {
      long long b = y22 - x2;
      s += b * (b + 1) / 2;
    }
    size += dif;
    dif += 4;
  }
  cout << ((0) > (h - 1) ? (0) : (h - 1)) << endl;
  return 0;
}
