#include <bits/stdc++.h>
using namespace std;
long long area(long long n) { return (n + 2) * (n + 2) / 2 - 1 - n / 2; }
int main() {
  long long n, x, y, c;
  cin >> n >> x >> y >> c;
  long long l = 0, r = 3 * n;
  while (l < r) {
    long long m = (l + r) / 2;
    long long k = 0, a;
    a = 4 * area(m) - 4 * m - 3;
    if (x + m > n) a -= (area(x + m - n - 1) * 2 - (x + m - n));
    if (x - m < 1) a -= (area(1 + m - x - 1) * 2 - (1 + m - x));
    if (y + m > n) a -= (area(y + m - n - 1) * 2 - (y + m - n));
    if (y - m < 1) a -= (area(1 + m - y - 1) * 2 - (1 + m - y));
    if (m - (n - y) - 1 - (n - x) - 1 >= 0)
      a += area(m - (n - y) - 1 - (n - x) - 1);
    if (m + 1 - y - (n - x) - 2 >= 0) a += area(m + 1 - y - (n - x) - 2);
    if (m - (n - y) - x - 1 >= 0) a += area(m - (n - y) - x - 1);
    if (m + 1 - y - x - 1 >= 0) a += area(m + 1 - y - x - 1);
    k = a;
    if (k >= c)
      r = m;
    else
      l = m + 1;
  }
  cout << r;
}
