#include <stdio.h>
#include <math.h>
#define pi 3.141592653589793238462
int main()
{
    int a, b, h, m;
    double hour_angle, minite_angle, angle, degree, result;
    scanf("%d %d %d %d", &a, &b, &h, &m);
    hour_angle = h * 30 + m * 0.5;
    minite_angle = m * 6.0;
    if (hour_angle >= minite_angle)
    {
        angle = hour_angle - minite_angle;
    }
    else
    {
        angle = minite_angle - hour_angle;
    }
    degree = (pi / 180) * angle;
    result = sqrt(a * a + b * b - 2 * a * b * cos(degree));
    printf("%.20lf", result);

    return 0;
}