Description:

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 ≤ nc ≤ 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. 

CodeForces - 255D_#include

.

在初始某一个位置有一个点这个点每一秒会向四个方向扩散,然后求第几秒的时候可以超过K个

找一个最小符合条件的,我们可以二分枚举答案来做,然后我们怎么求时间为 t 时细胞的总数呢  假设边界是无穷大的

我们先写出前四秒 1   5   13    25   41我们先假设第0秒为1,第一秒就是1+4*1,第二秒就是  5+4*2,第三秒是13+4*3,

第四秒是25+4*4  不难发现规律  a【t】=a【t-1】+4*t,然后求得公式就是2*t*t+2*t+1。

加上边界条件以后就是减去超出边界的

 假设到 某一边的距离为 x  超出就为 2 * (t - 1 - x) * (t - 1 - x + 1) / 2  +  t -  x 这个方向两边都超出了

再然后就是超出的部分有相交的部分 就是角上  假设点到达该角对应两边的距离为 x y 那超出部分为 (t-1-x-y)(t-1-x-y+1)/2

AC代码:

/*

MMM
MMMMMMM:
~MM MMM
7M+ MM
MM
MMMMMM, MM MM ,,:+MMM:
MMM MMM MM~ MM ~MMMMMMMMMMMMMMMMMMMMMMM$
ZM$ MMM MM MMMMMMMMMN MMM MMM$
MM MM8 MM OMMMMMO MM MM~
,MM MM ,MMMMM MM MMMMMMZ ,MM MMM
MM? MMDMMMMM+ , MM MM, ~MD , MM
MM8 :MMMO IMMM, MMÁÁÁÁ MM MM MMM ,MMO MM
MMM MMMMM MMMMMMM MM M8 MM MMM MM NM
MMMMMM MM ~MM MM7 MM MM7 DM
7MMM MM ÁÁÁÁ MM MMMMMM MM? MM
MMM M MM MM MMD :MM
MMM MMM IMM NMMM IMM
NMM 7MMMMMM MMMMMMMMM
MMM
MM MMM
MM DMM? MMM:
7MM MMMMMMMMMM MMMM
MM MMM MMMN MMMMMM7
MM MM MMD MMMMM
DM~ MM MM MM
NM MM MM MM=
MM MM NM MM
NM +MM MM NM MM
OM? MMM 8MM ,MM ZMZ
MM MMMM :MMM +? MMM MM
MM MMMMMMM: MM =MM +MM
MM: MMM MMM MM
MM MMMMMMMMMMMMM? MM
MM+ ?MMMMM$ MM7
MM MM
MM MM
=MM ZMM
MMM MMMM
~MMMMM MMMMMM
MM ?MMMM 8MMMM MM
MM MMMMMMN, NMMMMM ,MM
ZMM =MMMMMMMMMMMMMM DMM
,MMMMOMM8 MM7MMMM
MMM? MMM, MMMM ,MMM +MMM MMM
MM MMMM 7MMM MM MM ?MMM 8MMM8 M
:MMM NMM~ MM MM MMM MMMM
MO MM MM MM DMI ?ND
~M,ZMNIM MM 8MM :M M$ MM
MM MM MM MOM8MMM
~ MM MM D
OM? ~MM
MMMM MM MM
M MM M= MM =MM
MM M~MMMMNMMN MN
M M,MM+M?MM MM
MNOMMM ,,NDMM MM
MMM MM
MM MM
+M$ MM
MM MM
MM MM
MMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNDDZZZZIIIIIIIZZZDNMMMMM
, :~IZ8DNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN
NM MZ MM M
NM M7 MM7M
NM M+ MMDM
DM M= MMMM
DM M MMMM ZM=
DMMMMMMMMMMMMN MMMMMMMMMMMMM=
MM MM MM MM
~MMMMMMMMMMMM8 +MMMMMMMMMMMM
*/

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<math.h>
using namespace std;
typedef long long ll;
typedef double ld;
const int INF = 0x3f3f3f3f;
const int N=5000;
int i,j,k;
int p,q;
int res,cnt,ans,temp;
ll n,x,y,m;
ll cul(ll p)
{
if(p<=0)
return 0;
return
(p+1)*p/2;
}
int judge(ll p)
{
ll a=x-1,b=y-1,c=n-x,d=n-y;
ll ans=min(p,a)+min(p,b)+min(p,c)+min(p,d)+1;
p--;
ans+=cul(p)*4-2*cul(p-a)-2*cul(p-b)-2*cul(p-c)-2*cul(p-d);
ans+=cul(p-a-b)+cul(p-b-c)+cul(p-c-d)+cul(p-d-a);
return ans>=m;
}
int main()
{
scanf("%lld %lld %lld %lld",&n,&x,&y,&m);
ll l=0,r=1e9,ans=0;
while(l<=r)
{
ll mid=(r+l)>>1;
if(judge(mid))
{
ans=mid;
r=mid-1;
}
else l=mid+1;
}
printf("%lld\n",ans);
return 0;
}