#include <bits/stdc++.h>
using namespace std;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
const double EPS = 1e-8;
const double PI = acos(-1.0);
int popcount(int n) { return __builtin_popcount(n); }
int popcount(long long n) { return __builtin_popcountll(n); }
template <class T>
int SIZE(T a) {
  return a.size();
}
template <class T>
string IntToString(T num) {
  string res;
  stringstream ss;
  ss << num;
  return ss.str();
}
template <class T>
T StringToInt(string str) {
  T res = 0;
  for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0');
  return res;
}
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
void PrintSeq(T &a, int sz) {
  for (int i = 0; i < sz; i++) {
    cout << a[i];
    if (sz == i + 1)
      cout << endl;
    else
      cout << ' ';
  }
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
bool EQV(complex<double> a, complex<double> b) {
  return EQ(a.real(), b.real()) & EQ(a.imag(), b.imag());
}
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
  vector<string> res;
  for (int i = 0, s = 0; i < SIZE(str); i++) {
    if (str[i] == del) {
      if (i - s != 0) res.push_back(str.substr(s, i - s));
      s = i + 1;
    } else if (i == SIZE(str) - 1) {
      res.push_back(str.substr(s));
    }
  }
  return res;
}
long long N, X, Y, C;
long long getVal(long long a, long long mid) {
  if (mid - a < 0) return 0;
  return (mid - a + 1) * (mid - a + 2) / 2;
}
long long getVal2(long long a, long long mid) {
  if (mid - a < 0) return 0;
  return -mid + a - 1 + (mid - a + 1) * (mid - a + 2);
}
int main() {
  cin >> N >> X >> Y >> C;
  long long ub = 2 * N + 1;
  long long lb = -1;
  while (ub - lb > 1) {
    long long mid = (ub + lb) / 2;
    long long sum = -getVal((N + 1 - Y) + (N + 1 - X), mid);
    sum -= getVal(Y + (N + 1 - X), mid);
    sum -= getVal(X + (N + 1 - Y), mid);
    sum -= getVal(X + Y, mid);
    sum += getVal2(X, mid);
    sum += getVal2(Y, mid);
    sum += getVal2((N + 1 - X), mid);
    sum += getVal2((N + 1 - Y), mid);
    sum = -sum + mid * (mid + 1) * 2 + 1;
    if (sum >= C)
      ub = mid;
    else
      lb = mid;
  }
  cout << ub << endl;
  return 0;
}

### Prompt

Develop a solution in Cpp 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;
const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
const double EPS = 1e-8;
const double PI = acos(-1.0);
int popcount(int n) { return __builtin_popcount(n); }
int popcount(long long n) { return __builtin_popcountll(n); }
template <class T>
int SIZE(T a) {
  return a.size();
}
template <class T>
string IntToString(T num) {
  string res;
  stringstream ss;
  ss << num;
  return ss.str();
}
template <class T>
T StringToInt(string str) {
  T res = 0;
  for (int i = 0; i < SIZE(str); i++) res = (res * 10 + str[i] - '0');
  return res;
}
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
void PrintSeq(T &a, int sz) {
  for (int i = 0; i < sz; i++) {
    cout << a[i];
    if (sz == i + 1)
      cout << endl;
    else
      cout << ' ';
  }
}
bool EQ(double a, double b) { return abs(a - b) < EPS; }
bool EQV(complex<double> a, complex<double> b) {
  return EQ(a.real(), b.real()) & EQ(a.imag(), b.imag());
}
void fastStream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
vector<string> split(string str, char del) {
  vector<string> res;
  for (int i = 0, s = 0; i < SIZE(str); i++) {
    if (str[i] == del) {
      if (i - s != 0) res.push_back(str.substr(s, i - s));
      s = i + 1;
    } else if (i == SIZE(str) - 1) {
      res.push_back(str.substr(s));
    }
  }
  return res;
}
long long N, X, Y, C;
long long getVal(long long a, long long mid) {
  if (mid - a < 0) return 0;
  return (mid - a + 1) * (mid - a + 2) / 2;
}
long long getVal2(long long a, long long mid) {
  if (mid - a < 0) return 0;
  return -mid + a - 1 + (mid - a + 1) * (mid - a + 2);
}
int main() {
  cin >> N >> X >> Y >> C;
  long long ub = 2 * N + 1;
  long long lb = -1;
  while (ub - lb > 1) {
    long long mid = (ub + lb) / 2;
    long long sum = -getVal((N + 1 - Y) + (N + 1 - X), mid);
    sum -= getVal(Y + (N + 1 - X), mid);
    sum -= getVal(X + (N + 1 - Y), mid);
    sum -= getVal(X + Y, mid);
    sum += getVal2(X, mid);
    sum += getVal2(Y, mid);
    sum += getVal2((N + 1 - X), mid);
    sum += getVal2((N + 1 - Y), mid);
    sum = -sum + mid * (mid + 1) * 2 + 1;
    if (sum >= C)
      ub = mid;
    else
      lb = mid;
  }
  cout << ub << endl;
  return 0;
}

```