#include <bits/stdc++.h>
using namespace std;
long long n, x, y, c;
long long area(long long sec, long long base, long long altura) {
  long long a = min(altura, base);
  long long b = max(altura, base);
  if (sec >= a + b - 1) return a * b;
  if (sec <= a) return (sec * (sec + 1)) / 2;
  if (a < sec && sec <= b) return (a * (a + 1) / 2) + a * (sec - a);
  if (b < sec && sec < a + b - 1)
    return a * b - (((a + b - 1 - sec) * (a + b - sec)) / 2);
}
long long atot(long long sec) {
  long long res = area(sec, y - 1, x) + area(sec, x - 1, n - y + 1) +
                  area(sec, n - y, n - x + 1) + area(sec, n - x, y) + 1;
  return res;
}
long long bs(long long l, long long r) {
  long long mid = (l + r) / 2;
  if (r - l <= 1) {
    if (atot(l) >= c)
      return l;
    else
      return r;
  }
  if (atot(mid) >= c) {
    return bs(l, mid);
  } else
    return bs(mid, r);
}
int main() {
  cin >> n >> x >> y >> c;
  long long maxi = 2 * pow(10, 9);
  cout << bs(0, maxi) << endl;
}
