#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, y, c;
  while (cin >> n >> x >> y >> c) {
    long long num = 1;
    long long ans = -1;
    for (long long step = 1;; step++) {
      if (num >= c) {
        ans = step - 1;
        break;
      }
      long long dup = min(step, abs(x - 1));
      long long ddown = min(step, abs(x - n));
      long long dleft = min(step, abs(y - 1));
      long long dright = min(step, abs(y - n));
      if (dup == step) num++;
      if (ddown == step) num++;
      if (dleft == step) num++;
      if (dright == step) num++;
      long long t1, t2;
      t1 = min(dup, step - 1);
      t2 = min(dleft, step - 1);
      num += max(0LL, t1 + t2 - step + 1);
      t1 = min(dup, step - 1);
      t2 = min(dright, step - 1);
      num += max(0LL, t1 + t2 - step + 1);
      t1 = min(ddown, step - 1);
      t2 = min(dleft, step - 1);
      num += max(0LL, t1 + t2 - step + 1);
      t1 = min(ddown, step - 1);
      t2 = min(dright, step - 1);
      num += max(0LL, t1 + t2 - step + 1);
    }
    cout << ans << endl;
  }
  return 0;
}
