#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
long long n, x, y, c;
bool check(long long m) {
  long long ans = 2 * m * m + 2 * m + 1;
  if (x + m >= n) {
    ans -= (x + m - n) * (x + m - n);
  }
  if (x - m <= 0) {
    ans -= (m - x + 1) * (m - x + 1);
  }
  if (y + m >= n) {
    ans -= (y + m - n) * (y + m - n);
  }
  if (y - m <= 0) {
    ans -= (m - y + 1) * (m - y + 1);
  }
  if (x + m > n && y + m >= n) {
    long long num = x + m - n - n + y - 1;
    if (num > 0) {
      ans += num * (num + 1) / 2;
    }
  }
  if (x + m > n && y <= m) {
    long long num = m + x - y - n;
    if (num > 0) {
      ans += num * (num + 1) / 2;
    }
  }
  if (x <= m && y + m >= n) {
    long long num = m - x + y - n;
    if (num > 0) {
      ans += num * (num + 1) / 2;
    }
  }
  if (x <= m && y <= m) {
    long long num = (m - x + 1) - y;
    if (num > 0) {
      ans += num * (num + 1) / 2;
    }
  }
  return ans >= c;
}
int main() {
  cin >> n >> x >> y >> c;
  long long l = 0, r = 1e9;
  while (l < r) {
    long long mid = l + r >> 1;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << l;
  return 0;
}
