#include <bits/stdc++.h>
using namespace std;
int ans = 1, t, n, x, y, c, k;
int main() {
  cin >> n >> x >> y >> c;
  while (ans < c) {
    t++;
    k = min(x - 1, t);
    ans += max(k - max((y + t - n), 0) + 1, 0) +
           max(k - max((t - y + 1), 0) + 1, 0) - (k == t);
    k = min(n - x, t);
    ans += max(k - max((y + t - n), 1) + 1, 0) +
           max(k - max((t - y + 1), 1) + 1, 0) - (k == t);
  }
  cout << t;
}
