// dumb numerical solution, passes small tests

#include <cstdio>
#include <cassert>
#include <cmath>
#include <algorithm>

using namespace std;

#define N 1000
#define eps 1e-9

double h1, h2, d, l;

double sqr( double x ) { return x * x; }

double get( double h1, double h2 )
{
  double ans = h2;
  for (int i = 0; i <= N; i++)
  {
    double x1 = i * h1 / N;
    for (int j = 0; j <= N; j++)
    {
      double x2 = j * h2 / N;
      double ll = sqrt(d * d + sqr(x2 - x1));
      if (ll >= x2 || x1 - x2 + ll > l + eps)
        continue;
      if (h2 - x2 + ll < ans)
        ans = h2 - x2 + ll;
    }
  }
  return h1 + ans;
}

int main()
{
  freopen("joe.in", "r", stdin);
  freopen("joe.out", "w", stdout);
  scanf("%lf%lf%lf%lf", &d, &h1, &h2, &l);
  assert(0 < d && d <= 1000000);
  assert(0 < h1 && h1 <= 1000000);
  assert(0 < h2 && h2 <= 1000000);
  assert(0 < l && l <= 1000000);
  printf("%.15lf\n", min(get(h1, h2), get(h2, h1)));
  return 0;
}
