#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long n, x, y, c, lb, ub, mid;
inline long long sum(long long a) { return a * (a + 1) / 2; }
inline bool check() {
  long long ret = ((mid) * (mid)) + ((mid + 1) * (mid + 1)) -
                  ((max(0LL, mid - x + 1)) * (max(0LL, mid - x + 1))) -
                  ((max(0LL, mid - n + x)) * (max(0LL, mid - n + x))) -
                  ((max(0LL, mid - y + 1)) * (max(0LL, mid - y + 1))) -
                  ((max(0LL, mid - n + y)) * (max(0LL, mid - n + y))) +
                  sum(max(0LL, mid - x - (n - y + 1) + 1)) +
                  sum(max(0LL, mid - x - y + 1)) +
                  sum(max(0LL, mid - (n - x + 1) - y + 1)) +
                  sum(max(0LL, mid - (n - x + 1) - (n - y + 1) + 1));
  return ret >= c;
}
int main() {
  cin >> n >> x >> y >> c;
  lb = 0;
  ub = 1e8;
  while (lb < ub) {
    mid = (lb + ub) / 2;
    if (check())
      ub = mid;
    else
      lb = mid + 1;
  }
  cout << lb << endl;
  return 0;
}
