/* ex4_2
    riverstone*/

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

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; //時針と12の間のなす角度 [rad]
    double theta_m = 2 * M_PI * min/60; //分針と12の間のなす角度[rad]
    double theta = theta_h - theta_m; //時針と分針の間のなす角度[rad]
    
    //余弦定理より距離を求める
    double ans = sqrt(pow(len_h, 2) + pow(len_m, 2) - 2*len_h*len_m * cos(theta)); 
 
    printf("%.10f\n", ans); //ansを出力
 
    return 0;

}