import java.io.*;
import java.util.StringTokenizer;

/**
 * @author Roman V Satyukov
 */
public class joe_rs implements Runnable {
	private final String problemID = getClass().getName().split("_")[0].toLowerCase();
	private BufferedReader in;
	private PrintWriter out;
	
	private void check(boolean expr, String message) {
		if (!expr) {
			throw new AssertionError(message);
		}
	}
	
	private double calc(double d, double h1, double h2, double len) {
		double answer = h1;
		double x = (d * d - len * len) / 2 / len;
		h1 = Math.min(h1, h2 - x);
		double y = Math.hypot(d, h2 - h1);
		y = Math.min(y, h2);
		return answer + y;
	}

	private void solve() throws IOException {
		StringTokenizer st = new StringTokenizer(in.readLine());
		int d = Integer.parseInt(st.nextToken());
		int h1 = Integer.parseInt(st.nextToken());
		int h2 = Integer.parseInt(st.nextToken());
		int len = Integer.parseInt(st.nextToken());
		check((1 <= d) && (d <= 1000000), "d is not in [1..1000,000]");
		check((1 <= h1) && (h1 <= 1000000), "h1 is not in [1..1000,000]");
		check((1 <= h2) && (h2 <= 1000000), "h2 is not in [1..1000,000]");
		check((1 <= len) && (len <= 1000000), "L is not in [1..1000,000]");
		double answer = Math.min(calc(d, h1, h2, len), calc(d, h2, h1, len));
		out.println(answer);
	}
	
	public static void main(String[] args) {
		new Thread(new joe_rs()).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new FileReader(new File(problemID + ".in")));
			out = new PrintWriter(new File(problemID + ".out"));
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
