#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 * a * b * cos((M_PI * ((5.5 * m)-(30*h)))/180)));
    printf("%lf" , C);
    return 0;
}