#include <bits/stdc++.h>
using namespace std;
struct hren {
  long int pos, ob, tim;
};
hren down, up, lin, rech, u1, u2, u3, u4;
long long int c, q = 1, f = 1, g = 1;
long int n, j, i, timer = 0, x, y, p = 0;
void pere1(hren &q) {
  if (timer == q.tim) {
    q.pos = 1;
    q.ob = 1;
    return;
  }
  if (timer > q.tim) {
    q.pos += 2;
    q.ob += q.pos;
    return;
  }
}
void pere2(hren &q) {
  if (timer == q.tim) {
    q.pos = 1;
    q.ob = 1;
    return;
  }
  if (timer > q.tim) {
    q.pos += 1;
    q.ob += q.pos;
    return;
  }
}
void plusq(hren r) {
  if (r.ob > 0) q += r.ob;
  return;
}
void minusq(hren r) {
  if (r.ob > 0) q -= r.ob;
  return;
}
int main() {
  scanf("%d%d%d%I64d", &n, &x, &y, &c);
  down.tim = x;
  up.tim = n - x + 1;
  rech.tim = y;
  lin.tim = n - y + 1;
  u1.tim = n - y + x + 1;
  u3.tim = n - x + y + 1;
  u2.tim = x + y;
  u4.tim = 2 * n + 2 - x - y;
  while (1) {
    if (g >= c) {
      printf("%d", timer);
      return 0;
    }
    timer++;
    pere1(up);
    pere1(down);
    pere1(lin);
    pere1(rech);
    pere2(u1);
    pere2(u2);
    pere2(u3);
    pere2(u4);
    p += 4;
    f += p;
    q = 0;
    plusq(up);
    plusq(down);
    plusq(lin);
    plusq(rech);
    minusq(u1);
    minusq(u2);
    minusq(u3);
    minusq(u4);
    g = f - q;
  }
  return 0;
}

### Prompt

Create a solution in cpp for 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;
struct hren {
  long int pos, ob, tim;
};
hren down, up, lin, rech, u1, u2, u3, u4;
long long int c, q = 1, f = 1, g = 1;
long int n, j, i, timer = 0, x, y, p = 0;
void pere1(hren &q) {
  if (timer == q.tim) {
    q.pos = 1;
    q.ob = 1;
    return;
  }
  if (timer > q.tim) {
    q.pos += 2;
    q.ob += q.pos;
    return;
  }
}
void pere2(hren &q) {
  if (timer == q.tim) {
    q.pos = 1;
    q.ob = 1;
    return;
  }
  if (timer > q.tim) {
    q.pos += 1;
    q.ob += q.pos;
    return;
  }
}
void plusq(hren r) {
  if (r.ob > 0) q += r.ob;
  return;
}
void minusq(hren r) {
  if (r.ob > 0) q -= r.ob;
  return;
}
int main() {
  scanf("%d%d%d%I64d", &n, &x, &y, &c);
  down.tim = x;
  up.tim = n - x + 1;
  rech.tim = y;
  lin.tim = n - y + 1;
  u1.tim = n - y + x + 1;
  u3.tim = n - x + y + 1;
  u2.tim = x + y;
  u4.tim = 2 * n + 2 - x - y;
  while (1) {
    if (g >= c) {
      printf("%d", timer);
      return 0;
    }
    timer++;
    pere1(up);
    pere1(down);
    pere1(lin);
    pere1(rech);
    pere2(u1);
    pere2(u2);
    pere2(u3);
    pere2(u4);
    p += 4;
    f += p;
    q = 0;
    plusq(up);
    plusq(down);
    plusq(lin);
    plusq(rech);
    minusq(u1);
    minusq(u2);
    minusq(u3);
    minusq(u4);
    g = f - q;
  }
  return 0;
}

```