/* ex4_2
    suuxxu */

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979

int main(void){
    double len_hour, len_minute; // lengths of the hour hand and the minute hand
    double angle; // angle between the hour hand and the minute hand
    double hour, minute;
    double ans;

    // get inputs
    scanf("%lf %lf %lf %lf", &len_hour, &len_minute, &hour, &minute); // A B H M

    // calculate angle(rad)
    angle = (hour + minute / 60) / 12 * 2 * PI - minute / 60 * 2 * PI;

    // calculate answer(cm)
    // use law of cosines
    ans = sqrt(len_hour * len_hour + len_minute * len_minute - 2 * len_hour * len_minute * cos(angle));

    // output answer
    printf("%.10f\n", ans);

    return 0;
}