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

using namespace std;

#define N 1000
#define eps 1e-9

double h1, h2, d, l, bx1, bx2, ans;

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

void get( double h1a, double h1b, double h2a, double h2b )
{
  for (int i = 0; i <= N; i++)
  {
    double x1 = h1a + i * (h1b - h1a) / N;
    for (int j = N; j >= 0; j--)
    {
      double x2 = h2a + j * (h2b - h2a) / N;
      double ll = sqrt(d * d + sqr(x2 - x1));
      if (x1 - x2 + ll > l + eps)
        continue;
      if (h2 - x2 + ll + h1 < ans)
        ans = h2 - x2 + ll + h1, bx1 = x1, bx2 = x2;
    }
  }
}

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);
  if (h1 > h2)
    swap(h1, h2);
  ans = h1 + h2;
  bx1 = bx2 = 0.0;
  double dh1 = h1, dh2 = h2;
  for (int t = 0; t < 4; t++)
  {
    get(max(0.0, bx1 - dh1), min(h1, bx1 + dh1),
        max(0.0, bx2 - dh2), min(h2, bx2 + dh2));
    dh1 = dh1 / N * 2;
    dh2 = dh2 / N * 2;
  }
  printf("%.15lf\n", ans);
  return 0;
}
