#include <bits/stdc++.h>
using namespace std;
long long l, r, u, d, n, x, y, c;
bool judge(long long t) {
  long long ans = t * t + (t + 1) * (t + 1);
  if (t > l) ans -= (t - l) * (t - l);
  if (t > r) ans -= (t - r) * (t - r);
  if (t > u) ans -= (t - u) * (t - u);
  if (t > d) ans -= (t - d) * (t - d);
  if (t > l + d) ans += (t - l - d - 1) * (t - l - d) / 2;
  if (t > l + u) ans += (t - l - u - 1) * (t - l - u) / 2;
  if (t > r + d) ans += (t - r - d - 1) * (t - r - d) / 2;
  if (t > r + u) ans += (t - r - u - 1) * (t - r - u) / 2;
  if (ans >= c) return 1;
  return 0;
}
int main() {
  cin >> n >> x >> y >> c;
  l = x - 1;
  r = n - x;
  u = y - 1;
  d = n - y;
  long long le = 0, ri = 2 * n, mid;
  while (le <= ri) {
    mid = (le + ri) / 2;
    if (judge(mid))
      ri = mid - 1;
    else
      le = mid + 1;
  }
  cout << le << endl;
  return 0;
}
