#include <bits/stdc++.h>
using namespace std;
struct tout {
} out;
struct tin {
} in;
template <class T>
inline tout operator,(tout, const T &x) {
  cout << x;
  return tout();
}
template <class T>
inline tin operator,(tin, T &x) {
  cin >> x;
  return tin();
}
template <class T>
inline void rvc(vector<T> &mas, int number) {
  mas.resize(number);
  for (int i = 0; i < number; i++) cin >> mas[i];
}
template <class T>
inline void wvc(const vector<T> &mas, char delim = ' ') {
  for (size_t i = 0; i < mas.size(); i++) cout << mas[i] << delim;
}
template <class T>
inline istream &operator>>(istream &in, vector<T> &mas) {
  for (size_t i = 0; i < mas.size(); i++) in >> mas[i];
  return in;
}
template <class T>
inline ostream &operator<<(ostream &out, const vector<T> &mas) {
  for (size_t i = 0; i < mas.size(); i++) out << mas[i] << ' ';
  return out;
}
long long f(long long n) { return ((1 + n) * n) >> 1; }
long long f2(long long n) {
  if (n == 1) return 1;
  n--;
  return (2 + 2 * n) * n + 1;
}
long long f3(int n) { return 2 * f(abs(n)) - abs(n); }
int main() {
  int n, x, y, c;
  in, n, x, y, c;
  x--;
  y--;
  swap(x, y);
  int l = -1, r = 2 * n;
  while (l + 1 < r) {
    int cur = (l + r) >> 1;
    long long cnt = f2(cur + 1);
    int up = y - cur;
    if (up < 0) cnt -= f3(up);
    int down = y + cur;
    if (down >= n) {
      down -= n - 1;
      cnt -= f3(down);
    }
    int left = x - cur;
    if (left < 0) cnt -= f3(left);
    int right = x + cur;
    if (right >= n) {
      right -= n - 1;
      cnt -= f3(right);
    }
    int upright = cur - (y + abs(x - n));
    if (upright > 0) cnt += f(upright);
    int upleft = cur - (y + x + 1);
    if (upleft > 0) cnt += f(upleft);
    int downright = cur - (abs(n - 1 - y) + abs(n - x));
    if (downright > 0) cnt += f(downright);
    int downleft = cur - (abs(n - 1 - y) + x + 1);
    if (downleft > 0) cnt += f(downleft);
    if (cnt < c)
      l = cur;
    else
      r = cur;
  }
  cout << r;
  return 0;
}
