#include <bits/stdc++.h>
int IntMaxVal = (int)1e20;
int IntMinVal = (int)-1e20;
long long LongMaxVal = (long long)1e20;
long long LongMinVal = (long long)-1e20;
using namespace std;
template <typename T>
struct argument_type;
template <typename T, typename U>
struct argument_type<T(U)> {};
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& s) {
  is >> s.first >> s.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < v.size(); i++) os << v[i] << ' ';
  os << endl;
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, pair<T1, T2>& t) {
  s << t.first << ' ' << t.second;
  return s;
}
long long getCount(long long n, long long m, long long t) {
  if (t <= 1) return 0;
  if (n < m) return getCount(m, n, t);
  if (n * m == 0) return 0;
  t--;
  if (t <= m) return t * (t + 1) / 2;
  if (t <= n) return m * (m + 1) / 2 + m * (t - m);
  long long rem = n + m - 1 - t;
  { rem = max(rem, 0LL); };
  return n * m - rem * (rem + 1) / 2;
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  ;
  int x;
  cin >> x;
  ;
  int y;
  cin >> y;
  ;
  long long c;
  cin >> c;
  ;
  long long l = -1;
  long long r = 2 * n;
  while (l + 1 < r) {
    long long t = (l + r) / 2;
    long long res = 1;
    long long left = x - 1;
    long long top = y - 1;
    long long right = n - 1 - left;
    long long bottom = n - 1 - top;
    res += min(left, t);
    res += min(top, t);
    res += min(right, t);
    res += min(bottom, t);
    res += getCount(left, top, t);
    res += getCount(left, bottom, t);
    res += getCount(right, top, t);
    res += getCount(right, bottom, t);
    if (res >= c)
      r = t;
    else
      l = t;
  }
  cout << r;
}

### Prompt

Your challenge is to write 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>
int IntMaxVal = (int)1e20;
int IntMinVal = (int)-1e20;
long long LongMaxVal = (long long)1e20;
long long LongMinVal = (long long)-1e20;
using namespace std;
template <typename T>
struct argument_type;
template <typename T, typename U>
struct argument_type<T(U)> {};
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& s) {
  is >> s.first >> s.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < v.size(); i++) os << v[i] << ' ';
  os << endl;
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& s, pair<T1, T2>& t) {
  s << t.first << ' ' << t.second;
  return s;
}
long long getCount(long long n, long long m, long long t) {
  if (t <= 1) return 0;
  if (n < m) return getCount(m, n, t);
  if (n * m == 0) return 0;
  t--;
  if (t <= m) return t * (t + 1) / 2;
  if (t <= n) return m * (m + 1) / 2 + m * (t - m);
  long long rem = n + m - 1 - t;
  { rem = max(rem, 0LL); };
  return n * m - rem * (rem + 1) / 2;
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  ;
  int x;
  cin >> x;
  ;
  int y;
  cin >> y;
  ;
  long long c;
  cin >> c;
  ;
  long long l = -1;
  long long r = 2 * n;
  while (l + 1 < r) {
    long long t = (l + r) / 2;
    long long res = 1;
    long long left = x - 1;
    long long top = y - 1;
    long long right = n - 1 - left;
    long long bottom = n - 1 - top;
    res += min(left, t);
    res += min(top, t);
    res += min(right, t);
    res += min(bottom, t);
    res += getCount(left, top, t);
    res += getCount(left, bottom, t);
    res += getCount(right, top, t);
    res += getCount(right, bottom, t);
    if (res >= c)
      r = t;
    else
      l = t;
  }
  cout << r;
}

```