#include <bits/stdc++.h>
using namespace std;
long long int ff(long long int v) {
  if (v % 2LL == 0LL)
    return (v / 2) * (v + 1);
  else
    return ((v + 1) / 2) * v;
}
long long int cnt(long long int n, long long int x, long long int y,
                  long long int t) {
  long long int res = t * t + (t + 1) * (t + 1);
  long long int v0 = max(1 - x + t, 0LL);
  long long int v1 = max(1 - y + t, 0LL);
  long long int v2 = max(x + t - n, 0LL);
  long long int v3 = max(y + t - n, 0LL);
  long long int w0 = max(t - x - y + 1, 0LL);
  long long int w1 = max(t + x - y - n, 0LL);
  long long int w2 = max(t + x + y - 2 * n - 1, 0LL);
  long long int w3 = max(t - x + y - n, 0LL);
  res -= v0 * v0;
  res += ff(w0);
  res -= v1 * v1;
  res += ff(w1);
  res -= v2 * v2;
  res += ff(w2);
  res -= v3 * v3;
  res += ff(w3);
  return res;
}
int main() {
  long long int n, x, y, c;
  cin >> n >> x >> y >> c;
  long long int lb = 0, ub = 2 * n;
  while (ub - lb > 10LL) {
    long long int md = (lb + ub) / 2;
    if (cnt(n, x, y, md) >= c)
      ub = md;
    else
      lb = md;
  }
  long long int ans = lb;
  for (; ans <= ub && cnt(n, x, y, ans) < c; ans++)
    ;
  cout << ans << endl;
  return 0;
}

### Prompt

Please formulate a CPP solution to the following problem:

Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.

We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right from 1 to n. Initially there is exactly one switched on cell with coordinates (x, y) (x is the row number, y is the column number), and all other cells are switched off. Then each second we switch on the cells that are off but have the side-adjacent cells that are on.

For a cell with coordinates (x, y) the side-adjacent cells are cells with coordinates (x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1).

In how many seconds will Mr. Bender get happy?

Input

The first line contains four space-separated integers n, x, y, c (1 ≤ n, c ≤ 109; 1 ≤ x, y ≤ n; c ≤ n2).

Output

In a single line print a single integer — the answer to the problem.

Examples

Input

6 4 3 1


Output

0


Input

9 3 8 10


Output

2

Note

Initially the first test has one painted cell, so the answer is 0. In the second test all events will go as is shown on the figure. <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int ff(long long int v) {
  if (v % 2LL == 0LL)
    return (v / 2) * (v + 1);
  else
    return ((v + 1) / 2) * v;
}
long long int cnt(long long int n, long long int x, long long int y,
                  long long int t) {
  long long int res = t * t + (t + 1) * (t + 1);
  long long int v0 = max(1 - x + t, 0LL);
  long long int v1 = max(1 - y + t, 0LL);
  long long int v2 = max(x + t - n, 0LL);
  long long int v3 = max(y + t - n, 0LL);
  long long int w0 = max(t - x - y + 1, 0LL);
  long long int w1 = max(t + x - y - n, 0LL);
  long long int w2 = max(t + x + y - 2 * n - 1, 0LL);
  long long int w3 = max(t - x + y - n, 0LL);
  res -= v0 * v0;
  res += ff(w0);
  res -= v1 * v1;
  res += ff(w1);
  res -= v2 * v2;
  res += ff(w2);
  res -= v3 * v3;
  res += ff(w3);
  return res;
}
int main() {
  long long int n, x, y, c;
  cin >> n >> x >> y >> c;
  long long int lb = 0, ub = 2 * n;
  while (ub - lb > 10LL) {
    long long int md = (lb + ub) / 2;
    if (cnt(n, x, y, md) >= c)
      ub = md;
    else
      lb = md;
  }
  long long int ans = lb;
  for (; ans <= ub && cnt(n, x, y, ans) < c; ans++)
    ;
  cout << ans << endl;
  return 0;
}

```