#include <stdio.h>
#include <math.h>
 
int main(void)
{
    double a, b, h, m, C;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    C=sqrt((a * a)+(b * b)-(2.0 * a * b * cos((M_PI * ((5.5 * m)-(30*h)))/180.0)));
    printf("%.10f" , C);
    return 0;
}