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

public class joe_md implements Runnable {
	private Scanner in;
	private PrintWriter out;

	public void solve() {
		int d = in.nextInt();
		int h1 = in.nextInt();
		int h2 = in.nextInt();
		int len = in.nextInt();
		out.println(Math.min(solve(d, h1, h2, len), solve(d, h2, h1, len)));
	}
	
	private double solve(double d, int a, int b, double len) {
		double h = Math.max(b - a, (d * d - len * len) * 0.5 / len);
		return a + Math.min(Math.sqrt(d * d + h * h), b);
	}

	@Override
	public void run() {
		try {
			in = new Scanner(new FileReader("joe.in"));
			out = new PrintWriter(new File("joe.out"));
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new Thread(new joe_md()).start();
	}
}
