#include <bits/stdc++.h>
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  itval(++it, args...);
}
const long long int MOD = 1e9 + 7;
template <typename T>
inline void print(T x) {
  cout << x << "\n";
}
template <typename T>
inline void printvec(T x) {
  for (auto a : x) cout << a << ' ';
  cout << '\n';
}
struct custom {
  bool operator()(
      const pair<pair<long long int, long long int>, long long int> &p1,
      const pair<pair<long long int, long long int>, long long int> &p2) const {
    if (p1.first.first == p2.first.first) {
      return p1.first.second < p2.first.second;
    }
    return p1.first.first < p2.first.first;
  }
};
long long int get_pow(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
const long long int N = 1e5 + 5, inf = 4e18;
void solve() {
  long long int n, x, y, c;
  cin >> n >> x >> y >> c;
  long long int lo = 0, hi = 1e5 + 2;
  if (c == 1) {
    cout << 0;
    return;
  }
  while (lo + 1 < hi) {
    long long int mid = (lo + hi) / 2, dx, dy, by, upy;
    long long int tot = 0;
    for (long long int i = (long long int)0; i < (long long int)(mid + 1);
         i++) {
      dy = mid - i;
      by = max(1ll, y - dy);
      upy = min(n, y + dy);
      if (x + i <= n) {
        tot += (upy - by + 1);
      }
      if (x - i >= 1 && i > 0) {
        tot += (upy - by + 1);
      }
    }
    if (tot >= c) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << hi << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  clock_t z = clock();
  for (long long int tes = (long long int)0; tes < (long long int)(test);
       tes++) {
    solve();
  }
  fprintf(stderr, "Total Time:%.4f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}

### Prompt

Your task is to create 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>
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  itval(++it, args...);
}
const long long int MOD = 1e9 + 7;
template <typename T>
inline void print(T x) {
  cout << x << "\n";
}
template <typename T>
inline void printvec(T x) {
  for (auto a : x) cout << a << ' ';
  cout << '\n';
}
struct custom {
  bool operator()(
      const pair<pair<long long int, long long int>, long long int> &p1,
      const pair<pair<long long int, long long int>, long long int> &p2) const {
    if (p1.first.first == p2.first.first) {
      return p1.first.second < p2.first.second;
    }
    return p1.first.first < p2.first.first;
  }
};
long long int get_pow(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
const long long int N = 1e5 + 5, inf = 4e18;
void solve() {
  long long int n, x, y, c;
  cin >> n >> x >> y >> c;
  long long int lo = 0, hi = 1e5 + 2;
  if (c == 1) {
    cout << 0;
    return;
  }
  while (lo + 1 < hi) {
    long long int mid = (lo + hi) / 2, dx, dy, by, upy;
    long long int tot = 0;
    for (long long int i = (long long int)0; i < (long long int)(mid + 1);
         i++) {
      dy = mid - i;
      by = max(1ll, y - dy);
      upy = min(n, y + dy);
      if (x + i <= n) {
        tot += (upy - by + 1);
      }
      if (x - i >= 1 && i > 0) {
        tot += (upy - by + 1);
      }
    }
    if (tot >= c) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  cout << hi << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  clock_t z = clock();
  for (long long int tes = (long long int)0; tes < (long long int)(test);
       tes++) {
    solve();
  }
  fprintf(stderr, "Total Time:%.4f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}

```