/*  ex4_2
    Graku   */
#include <stdio.h>
#include<math.h>
//#define PI = 3.1415926535

int main(void) {
    double len_h, len_m, hour, min;
    scanf("%lf %lf %lf %lf", &len_h, &len_m, &hour, &min);

    double theta_h = 2 * M_PI * (hour + min/60)/12; //angle between 0 and hour hands [rad]
    double theta_m = 2 * M_PI * min/60; //angle between 0 and minute hands [rad]
    double theta = theta_h - theta_m; //angle between hour and minute hands [rad]

    double ans = sqrt(pow(len_h, 2) + pow(len_m, 2) - 2*len_h*len_m * cos(theta)); //cosine theorem

    printf("%.10f\n", ans); //10 decimal places

    return 0;
}