#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef long double ld;

const ld eps = 1.0e-9; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

int main (void)
{
    long double a, b, h, m, c;
    double theta, h_theta, m_theta;

    scanf("%Lf %Lf %Lf %Lf", &a, &b, &h, &m);

    h_theta = 360 * ((60 * h + m) / (60 * 12));
    m_theta = 360 * (m / 60);
    theta = M_PI*fabs(h_theta - m_theta)/180;

    c = pow(a, 2.0) + pow(b, 2.0) - (2 * b * a * cos(theta));

    printf("%.15Lf", mysqrtl(c));

    return 0;
}
