/* ex_4-2. nknm */

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

//関数を宣言
int length(double len_h, double len_m, double hour, double min);

int main(void){

    double len_h, len_m, hour, min, ans;

    scanf("%lf%lf%lf%lf", &len_h, &len_m, &hour, &min);

    //関数の計算結果を出力
    ans = length(len_h, len_m, hour, min);
    printf("%.9f\n", ans);
    
    return 0;
}

int length(double len_h, double len_m, double hour, double min){
    double result, ang;
    ang = cos((2 * M_PI * min / 60) - ((2 * M_PI * hour / 12) + (2 * M_PI * min /12 / 60)));
    result = sqrt(len_h * len_h + len_m * len_m - 2 * len_h * len_m * ang);

    return result;
}