/* ex4_2
  sachiyan */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void){
    int len_hour, len_minute, hour, minute;
    double degree, difference, radian, cosine, answer;
    double pi = acos(-1);
    scanf("%d %d %d %d", &len_hour, &len_minute, &hour, &minute);
    degree = 0.5*(60*hour + minute) - 6*minute;
    difference = fabs(degree);

    if (difference <= 180){
        radian = difference*(pi/180);
        answer = sqrt(len_hour*len_hour + len_minute*len_minute - 2*len_hour*len_minute*cos(radian));
        printf("%.20lf\n", answer);
    }
    else{
        radian = (360 - difference)*(pi/180);
        answer = sqrt(len_hour*len_hour + len_minute*len_minute - 2*len_hour*len_minute*cos(radian));
        printf("%.20lf\n", answer);
    }

    return 0;
}