#include <bits/stdc++.h>
using namespace std;
template <class T1>
void debug(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void debug(T1 e1, T2 e2) {
  cout << e1 << "\t" << e2 << endl;
}
template <class T1, class T2, class T3>
void debug(T1 e1, T2 e2, T3 e3) {
  cout << e1 << "\t" << e2 << "\t" << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void debug(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void debug(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void debug(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << "\t"
       << e6 << endl;
}
template <class T>
void debug(vector<vector<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << " ";
    cout << endl;
  }
  cout << endl;
}
template <class T>
void debug(vector<basic_string<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
template <class T>
void debug(T e[110][110], int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << " ";
    cout << endl;
  }
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool isVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
long long n, x, y, c;
long long a1, b1, a2, b2, a3, b3, a4, b4;
long long tri(long long n) {
  if (n <= 0) return 0;
  return (n * (n + 1)) / 2;
}
long long cnt(long long a, long long b, long long t) {
  if (!a || !b) return 0;
  long long dif = t - a + 1;
  long long ret = 0;
  if (dif > 0) ret += min(dif, b) * a;
  if (t < a + b - 1) ret += tri(min(t, a - 1)) - tri(t - b);
  return ret;
}
bool chc(long long t) {
  if (cnt(a1, b1, t) + cnt(a2, b2, t) + cnt(a3, b3, t) + cnt(a4, b4, t) >=
      c - 1)
    return true;
  return false;
}
long long bs(long long st, long long end) {
  if (st == end) return st;
  long long mid = (st + end) / 2;
  if (!chc(mid)) return bs(mid + 1, end);
  if (!mid || !chc(mid - 1)) return mid;
  return bs(st, mid - 1);
}
int main() {
  while (cin >> n >> x >> y >> c) {
    a1 = x - 1;
    b1 = y;
    a2 = x;
    b2 = n - y;
    a3 = n - x + 1;
    b3 = y - 1;
    a4 = n - x;
    b4 = n - y + 1;
    cout << bs(0, 4000000000ll) << endl;
  }
  return 0;
}
