#include <stdio.h>
#include <math.h>
#define PI 3.1425926535

int main(void)
{
    int a, b, h, m;
    double s, l;

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

    if ((double)(2 * PI * m / 60) >= (double)((2 * PI * h / 12) + (2 * PI / 12) * (m / 60)))
    {
        s = (double)(2 * PI * m / 60) - (double)((2 * PI * h / 12) + (2 * PI / 12) * (m / 60));
        l = sqrtl(a * a + b * b - 2 * a * b * cosl(s));
        printf("%.11f", l);
    }

    if ((double)(2 * PI * m / 60) == (double)((2 * PI * h / 12) + (2 * PI / 12) * (m / 60)))
    {
        l = 0.0;
        printf("%.11f", l);
    }

    if ((double)(2 * PI * m / 60) <= (double)((2 * PI * h / 12) + (2 * PI / 12) * (m / 60)))
    {
        s = fabs((double)(2 * PI * m / 60) - (double)((2 * PI * h / 12) + (2 * PI / 12) * (m / 60)));
        l = sqrtl(a * a + b * b - 2 * a * b * cosl(s));
        printf("%.11f", l);
    }

    return 0;
}