#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:46777216")
using namespace std;
struct intervalTree {
  int n;
  long long *t;
  void init(int m) {
    n = m;
    t = new long long[4 * n];
  }
  void build(long long a[], int v, int tl, int tr);
  long long elem_query(int pos, int v, int tl, int tr);
  long long sum_query(int l, int r, int v, int tl, int tr);
  void update(int l, int r, long long new_val, int v, int tl, int tr);
};
void intervalTree::build(long long a[], int v = 1, int tl = 0, int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (tl == tr)
    t[v] = a[tl];
  else {
    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm + 1, tr);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long intervalTree::elem_query(int pos, int v = 1, int tl = 0,
                                   int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (tl == tr) return t[v];
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    return t[v] + elem_query(pos, v * 2, tl, tm);
  else
    return t[v] + elem_query(pos, v * 2 + 1, tm + 1, tr);
}
long long intervalTree::sum_query(int l, int r, int v = 1, int tl = 0,
                                  int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return sum_query(l, min(r, tm), v * 2, tl, tm) +
         sum_query(max(l, tm + 1), r, v * 2 + 1, tm + 1, tr);
}
void intervalTree::update(int l, int r, long long add, int v = 1, int tl = 0,
                          int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (tl == tr)
    t[v] += add;
  else {
    int tm = (tl + tr) / 2;
    if (r <= tm)
      update(l, r, add, v * 2, tl, tm);
    else if (l > tm)
      update(l, r, add, v * 2 + 1, tm + 1, tr);
    else {
      update(l, tm, add, v * 2, tl, tm);
      update(tm + 1, r, add, v * 2 + 1, tm + 1, tr);
    }
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long F(long long n, long long x, long long y, long long c) {
  long long h = c + 1;
  long long ans = h * (h - 1) * 2 + 1;
  if (x + h > n + 1) ans -= (x + h - n - 1) * (x + h - n - 1);
  if (y + h > n + 1) ans -= (y + h - n - 1) * (y + h - n - 1);
  if (h > x) ans -= (h - x) * (h - x);
  if (h > y) ans -= (h - y) * (h - y);
  if (y + h - x - n - 1 > 0) ans += (y + h - x - n) * (y + h - x - n - 1) / 2;
  if (h - x - y > 0) ans += (h - x - y) * (h - x - y + 1) / 2;
  if (x + h - n - y - 1 > 0) ans += (x + h - n - y) * (x + h - n - y - 1) / 2;
  if (x + y + h - 2 * n - 2 > 0)
    ans += (x + y + h - 2 * n - 2) * (x + y + h - 2 * n - 1) / 2;
  return ans;
}
int main() {
  long long n, x, y, key;
  cin >> n >> x >> y >> key;
  long long lb = 0, ub = 1000000000;
  if (F(n, x, y, 0) >= key) {
    cout << 0;
    return 0;
  }
  while (true) {
    long long M = (lb + ub) / 2;
    if (F(n, x, y, M) >= key)
      ub = M - 1;
    else if (F(n, x, y, M + 1) < key)
      lb = M + 1;
    else {
      cout << M + 1;
      break;
    }
  }
  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>
#pragma comment(linker, "/STACK:46777216")
using namespace std;
struct intervalTree {
  int n;
  long long *t;
  void init(int m) {
    n = m;
    t = new long long[4 * n];
  }
  void build(long long a[], int v, int tl, int tr);
  long long elem_query(int pos, int v, int tl, int tr);
  long long sum_query(int l, int r, int v, int tl, int tr);
  void update(int l, int r, long long new_val, int v, int tl, int tr);
};
void intervalTree::build(long long a[], int v = 1, int tl = 0, int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (tl == tr)
    t[v] = a[tl];
  else {
    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm + 1, tr);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long intervalTree::elem_query(int pos, int v = 1, int tl = 0,
                                   int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (tl == tr) return t[v];
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    return t[v] + elem_query(pos, v * 2, tl, tm);
  else
    return t[v] + elem_query(pos, v * 2 + 1, tm + 1, tr);
}
long long intervalTree::sum_query(int l, int r, int v = 1, int tl = 0,
                                  int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int tm = (tl + tr) / 2;
  return sum_query(l, min(r, tm), v * 2, tl, tm) +
         sum_query(max(l, tm + 1), r, v * 2 + 1, tm + 1, tr);
}
void intervalTree::update(int l, int r, long long add, int v = 1, int tl = 0,
                          int tr = -1) {
  if (tr == -1) tr = n - 1;
  if (tl == tr)
    t[v] += add;
  else {
    int tm = (tl + tr) / 2;
    if (r <= tm)
      update(l, r, add, v * 2, tl, tm);
    else if (l > tm)
      update(l, r, add, v * 2 + 1, tm + 1, tr);
    else {
      update(l, tm, add, v * 2, tl, tm);
      update(tm + 1, r, add, v * 2 + 1, tm + 1, tr);
    }
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long F(long long n, long long x, long long y, long long c) {
  long long h = c + 1;
  long long ans = h * (h - 1) * 2 + 1;
  if (x + h > n + 1) ans -= (x + h - n - 1) * (x + h - n - 1);
  if (y + h > n + 1) ans -= (y + h - n - 1) * (y + h - n - 1);
  if (h > x) ans -= (h - x) * (h - x);
  if (h > y) ans -= (h - y) * (h - y);
  if (y + h - x - n - 1 > 0) ans += (y + h - x - n) * (y + h - x - n - 1) / 2;
  if (h - x - y > 0) ans += (h - x - y) * (h - x - y + 1) / 2;
  if (x + h - n - y - 1 > 0) ans += (x + h - n - y) * (x + h - n - y - 1) / 2;
  if (x + y + h - 2 * n - 2 > 0)
    ans += (x + y + h - 2 * n - 2) * (x + y + h - 2 * n - 1) / 2;
  return ans;
}
int main() {
  long long n, x, y, key;
  cin >> n >> x >> y >> key;
  long long lb = 0, ub = 1000000000;
  if (F(n, x, y, 0) >= key) {
    cout << 0;
    return 0;
  }
  while (true) {
    long long M = (lb + ub) / 2;
    if (F(n, x, y, M) >= key)
      ub = M - 1;
    else if (F(n, x, y, M + 1) < key)
      lb = M + 1;
    else {
      cout << M + 1;
      break;
    }
  }
  return 0;
}

```