#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const bool debug = true;
const long long INFL = LLONG_MAX;
const int output_precision = 15;
stringstream ss;
long long N, X0, Y0, C;
long long f(long long s, long long x, long long y) {
  if (x > y) swap(x, y);
  s++;
  if (s <= x) return (s * (s + 1)) / 2;
  if (s <= y) return ((x * (x + 1)) / 2) + (s - x) * x;
  if (s <= (x + y - 1)) return x * y - ((x + y - s) * (x + y - s - 1)) / 2;
  return x * y;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(output_precision);
  cout << fixed;
  ss.precision(output_precision);
  ss << fixed;
  cin >> N >> X0 >> Y0 >> C;
  if (0 == 1) {
    int s = 2;
    {
      if (debug) {
        cout << "f(s, X0, Y0)"
             << " = " << (f(s, X0, Y0)) << '\n';
      }
    };
    {
      if (debug) {
        cout << "f(s, X0, N - Y0 + 1)"
             << " = " << (f(s, X0, N - Y0 + 1)) << '\n';
      }
    };
    {
      if (debug) {
        cout << "f(s, N - X0 + 1, Y0)"
             << " = " << (f(s, N - X0 + 1, Y0)) << '\n';
      }
    };
    {
      if (debug) {
        cout << "f(s, N - X0 + 1, N - Y0 + 1)"
             << " = " << (f(s, N - X0 + 1, N - Y0 + 1)) << '\n';
      }
    };
    exit(0);
  }
  if (C == 1) {
    cout << 0 << '\n';
    return 0;
  } else {
    long long bad = 0;
    long long good = N * 2;
    while (bad + 1 < good) {
      long long s = (good + bad) >> 1;
      long long sum = 0;
      sum += f(s, X0, Y0);
      sum += f(s, X0, N - Y0 + 1);
      sum += f(s, N - X0 + 1, Y0);
      sum += f(s, N - X0 + 1, N - Y0 + 1);
      sum -= min(N - X0 + 1, s + 1);
      sum -= min(N - Y0 + 1, s + 1);
      sum -= min(X0, s + 1);
      sum -= min(Y0, s + 1);
      sum++;
      assert(sum >= 0);
      if (sum < C)
        bad = s;
      else
        good = s;
    }
    cout << good << '\n';
    return 0;
  }
}
