// Непротестированное решение

uses
	Math;
var
	d, h1, h2, l, t : int64;
	x, ans : extended;
begin
	reset(input, 'joe.in');
	rewrite(output, 'joe.out');

	read(d, h1, h2, l);
	if (h1 > h2) then begin
		t := h1;
		h1 := h2;
		h2 := t;
	end;
	                                         
	if (l <= d) then begin
		ans := h2;
	end else begin
		
		x := h2 + (d * d - l * l) / (2 * l);
		//writeln(x:0:5);
		if (x > h1) then
			x := h1;
		if (x < 0) then
			ans := h2
		else
			ans := sqrt(d * d + sqr(h2 - x));
	end;

	writeln((h1 + ans):0:5);

end.