#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, y, g;
  cin >> n >> x >> y >> g;
  long long a = y - 1;
  long long b = n - x;
  long long c = n - y;
  long long d = x - 1;
  long long on = 1;
  long long s = 0;
  while (on < g) {
    s++;
    on += 4 * s;
    if (s > a) on -= (s - a) * 2 - 1;
    if (s > b) on -= (s - b) * 2 - 1;
    if (s > c) on -= (s - c) * 2 - 1;
    if (s > d) on -= (s - d) * 2 - 1;
    if (s > (a + b) + 1) on += (s - (a + b + 1));
    if (s > (b + c) + 1) on += (s - (b + c + 1));
    if (s > (c + d) + 1) on += (s - (c + d + 1));
    if (s > (d + a) + 1) on += (s - (d + a + 1));
  }
  cout << s << endl;
  return 0;
}
