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