#include <bits/stdc++.h>
using namespace std;
long long int n, x, y, c;
long long int sq(long long int a) {
  if (a < 0) return 0;
  return a * a;
}
long long int tot(long long int x) {
  if (x < 1) return 0;
  return (x * (x + 1)) / 2;
}
long long int count(long long int sec) {
  long long int act = sec * sec * 2 + sec * 2 + 1;
  long long int extray = sq(sec + y - n) + sq(sec - y + 1);
  long long int extrax = sq(sec + x - n) + sq(sec - x + 1);
  long long int doub1 = 0;
  if (x + n + 1 - y <= sec) doub1 = tot(-(x + n + 1 - y) + sec + 1);
  long long int doub2 = 0;
  if (n + 1 - x + n + 1 - y <= sec)
    doub2 = tot(-(n + 1 - x + n + 1 - y) + sec + 1);
  long long int doub3 = 0;
  if (y + n + 1 - x <= sec) doub3 = tot(-(y + n + 1 - x) + sec + 1);
  long long int doub4 = 0;
  if (y + x <= sec) doub4 = tot(-(y + x) + sec + 1);
  return act - extray - extrax + doub1 + doub2 + doub3 + doub4;
}
int main() {
  cin >> n >> x >> y >> c;
  long long int ans, lb = 0, ub = 1000000000, mid;
  while (lb <= ub) {
    mid = ((lb + ub) >> 1);
    if (count(mid) >= c) {
      ans = mid;
      ub = mid - 1;
    } else
      lb = mid + 1;
  }
  cout << ans << endl;
  return 0;
}
