#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;
}
