#include<stdio.h>
#include<math.h>
const double PI = 3.14159265357;
int main(void) {
    int leng_of_hour, length_of_minute, h, m = 0;
    double degree,distance;
    scanf("%d %d %d %d", &leng_of_hour, &length_of_minute, &h, &m);
    degree = fabs((2*PI*h/12) - ((2*PI*m)/60));
    if (degree > PI ){
        degree -= PI;
    }
    distance = sqrt(leng_of_hour*leng_of_hour + length_of_minute * length_of_minute - 2 * leng_of_hour * length_of_minute * cos(degree));
    printf("%lf", distance);
    return 0;
}