#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
  Point() {}
  Point(long long tx, long long ty) {
    x = tx;
    y = ty;
  }
};
long long n, x, y, c;
long long l, r;
long long count(long long w, long long h, long long x, long long y,
                long long t) {
  long long dt;
  Point p[9];
  long long s = 0;
  if (x - t > 1) {
    dt = x - t - 1;
    return count(w - dt, h, x - dt, y, t);
  }
  if (y - t > 1) {
    dt = y - t - 1;
    return count(w, h - dt, x, y - dt, t);
  }
  if (x + t < w) {
    dt = w - x - t;
    return count(w - dt, h, x, y, t);
  }
  if (y + t < h) {
    dt = h - y - t;
    return count(w, h - dt, x, y, t);
  }
  dt = (t + 1) - x;
  p[0] = Point(0, y - 1 - dt);
  p[1] = Point(0, y + dt);
  dt = (y + t) - h;
  p[2] = Point(x - 1 - dt, h);
  p[3] = Point(x + dt, h);
  dt = (x + t) - w;
  p[4] = Point(w, y + dt);
  p[5] = Point(w, y - 1 - dt);
  dt = (t + 1) - y;
  p[6] = Point(x + dt, 0);
  p[7] = Point(x - 1 - dt, 0);
  for (int i = 0; i < 8; i++) {
    if (p[i].x < 0) p[i].x = 0;
    if (p[i].x > w) p[i].x = w;
    if (p[i].y < 0) p[i].y = 0;
    if (p[i].y > h) p[i].y = h;
  }
  p[8] = p[0];
  for (int i = 0; i < 8; i++) {
    s += (p[i + 1].x - p[i].x) * (p[i].y + p[i + 1].y);
  }
  if (s < 0) s = -s;
  for (int i = 1; i < 8; i += 2) {
    dt = p[i + 1].x - p[i].x;
    if (dt < 0) dt = -dt;
    s -= dt;
  }
  return s / 2;
}
long long fill(long long t) { return count(n, n, x, y, t); }
int main() {
  cin >> n >> x >> y >> c;
  l = -1, r = 1000000007;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (fill(m) < c) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << r;
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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;
struct Point {
  long long x, y;
  Point() {}
  Point(long long tx, long long ty) {
    x = tx;
    y = ty;
  }
};
long long n, x, y, c;
long long l, r;
long long count(long long w, long long h, long long x, long long y,
                long long t) {
  long long dt;
  Point p[9];
  long long s = 0;
  if (x - t > 1) {
    dt = x - t - 1;
    return count(w - dt, h, x - dt, y, t);
  }
  if (y - t > 1) {
    dt = y - t - 1;
    return count(w, h - dt, x, y - dt, t);
  }
  if (x + t < w) {
    dt = w - x - t;
    return count(w - dt, h, x, y, t);
  }
  if (y + t < h) {
    dt = h - y - t;
    return count(w, h - dt, x, y, t);
  }
  dt = (t + 1) - x;
  p[0] = Point(0, y - 1 - dt);
  p[1] = Point(0, y + dt);
  dt = (y + t) - h;
  p[2] = Point(x - 1 - dt, h);
  p[3] = Point(x + dt, h);
  dt = (x + t) - w;
  p[4] = Point(w, y + dt);
  p[5] = Point(w, y - 1 - dt);
  dt = (t + 1) - y;
  p[6] = Point(x + dt, 0);
  p[7] = Point(x - 1 - dt, 0);
  for (int i = 0; i < 8; i++) {
    if (p[i].x < 0) p[i].x = 0;
    if (p[i].x > w) p[i].x = w;
    if (p[i].y < 0) p[i].y = 0;
    if (p[i].y > h) p[i].y = h;
  }
  p[8] = p[0];
  for (int i = 0; i < 8; i++) {
    s += (p[i + 1].x - p[i].x) * (p[i].y + p[i + 1].y);
  }
  if (s < 0) s = -s;
  for (int i = 1; i < 8; i += 2) {
    dt = p[i + 1].x - p[i].x;
    if (dt < 0) dt = -dt;
    s -= dt;
  }
  return s / 2;
}
long long fill(long long t) { return count(n, n, x, y, t); }
int main() {
  cin >> n >> x >> y >> c;
  l = -1, r = 1000000007;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    if (fill(m) < c) {
      l = m;
    } else {
      r = m;
    }
  }
  cout << r;
  return 0;
}

```