#include <bits/stdc++.h>
using namespace std;
int N, X, Y;
long long M;
long long getval(int A, int B, int x) {
  if (A == 0 || B == 0) return 0;
  if (x >= A + B - 1) return 1LL * A * B;
  if (x <= min(A, B)) return 1LL * x * (x + 1) / 2;
  if (x > min(A, B) && x <= max(A, B))
    return 1LL * (x - min(A, B)) * min(A, B) +
           1LL * min(A, B) * (min(A, B) + 1) / 2;
  return 1LL * A * B - 1LL * (A + B - 1 - x) * (A + B - x) / 2;
}
bool Test(int x) {
  long long resnow = 1;
  resnow += min(x, X - 1);
  resnow += min(x, N - X);
  resnow += min(x, Y - 1);
  resnow += min(x, N - Y);
  resnow += getval(X - 1, Y - 1, x - 1);
  resnow += getval(X - 1, N - Y, x - 1);
  resnow += getval(N - X, Y - 1, x - 1);
  resnow += getval(N - X, N - Y, x - 1);
  return (resnow < M);
}
int main() {
  cin >> N >> X >> Y >> M;
  if (M == 1) {
    cout << 0 << '\n';
    return 0;
  }
  int step = 1 << 30, result;
  for (result = 0; step; step >>= 1)
    if (result + step <= 2 * N && Test(result + step)) result += step;
  ++result;
  cout << result << '\n';
}

### Prompt

Please create a solution in Cpp 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;
int N, X, Y;
long long M;
long long getval(int A, int B, int x) {
  if (A == 0 || B == 0) return 0;
  if (x >= A + B - 1) return 1LL * A * B;
  if (x <= min(A, B)) return 1LL * x * (x + 1) / 2;
  if (x > min(A, B) && x <= max(A, B))
    return 1LL * (x - min(A, B)) * min(A, B) +
           1LL * min(A, B) * (min(A, B) + 1) / 2;
  return 1LL * A * B - 1LL * (A + B - 1 - x) * (A + B - x) / 2;
}
bool Test(int x) {
  long long resnow = 1;
  resnow += min(x, X - 1);
  resnow += min(x, N - X);
  resnow += min(x, Y - 1);
  resnow += min(x, N - Y);
  resnow += getval(X - 1, Y - 1, x - 1);
  resnow += getval(X - 1, N - Y, x - 1);
  resnow += getval(N - X, Y - 1, x - 1);
  resnow += getval(N - X, N - Y, x - 1);
  return (resnow < M);
}
int main() {
  cin >> N >> X >> Y >> M;
  if (M == 1) {
    cout << 0 << '\n';
    return 0;
  }
  int step = 1 << 30, result;
  for (result = 0; step; step >>= 1)
    if (result + step <= 2 * N && Test(result + step)) result += step;
  ++result;
  cout << result << '\n';
}

```