Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.OutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author BSRK Aditya (bsrkaditya@gmail.com)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {

    long n,x,y,c;



	public void solve(int testNumber, InputReader in, OutputWriter out) {
        n = in.readInt();
        x = in.readInt();
        y = in.readInt();
        c = in.readInt();

        int lo = -1;
        int hi = (int)c;

        while(lo+1<hi) {
            int mi = (lo+hi)/2;
            if(P(mi)) hi = mi; else lo = mi;
        }
        out.printLine(hi);
	}

    private boolean P(int t) {
        if(t == -1) return false;

        int ans = 0;
        for(long i = Math.max(1,y-t); i <= Math.min(y+t,n); ++i) {
            long a = Math.abs(y - i);
            ans += D(Math.max(1,x-t+a), Math.min(n,x+t-a));
            if(ans >= c) return true;
        }

        return false;
    }

    private long D(long a, long b) {
        return b - a + 1;
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new... Complexity: