#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
double h1, h2, l, d, a, b, r;
cin >> d >> a >> b >> l;
h1 = min(a,b);
h2 = max(a,b);
double res = h1;
h1 = min (h1, (h2 - ((d*d - l*l)/(2*l))));
if (h1 < 0) r = h2;
else r = (sqrt(d*d + (h2-h1)*(h2-h1)));
res += min(r, h2);
cout << fixed << setprecision(5) << res;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxpb21hbmlwPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIHsKICAgIGRvdWJsZSBoMSwgaDIsIGwsIGQsIGEsIGIsIHI7CiAgICBjaW4gPj4gZCA+PiBhID4+IGIgPj4gbDsKICAgIGgxID0gbWluKGEsYik7CiAgICBoMiA9IG1heChhLGIpOwogICAgZG91YmxlIHJlcyA9IGgxOwogICAgaDEgPSBtaW4gKGgxLCAoaDIgLSAoKGQqZCAtIGwqbCkvKDIqbCkpKSk7CiAgICBpZiAoaDEgPCAwKSByID0gaDI7CiAgICBlbHNlIHIgPSAoc3FydChkKmQgKyAoaDItaDEpKihoMi1oMSkpKTsKICAgIHJlcyArPSBtaW4ociwgaDIpOwogICAgY291dCA8PCBmaXhlZCA8PCBzZXRwcmVjaXNpb24oNSkgPDwgcmVzOwogICAgcmV0dXJuIDA7Cn0K