/* ex4_2
  terakura */

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

int main(void){
    double short_hand, long_hand, hour, minute, angle, len;
    scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute );


//短針と０時０分が為す角は(時間/12)＊2π + (π/6の”分”ぶんの60)、長針と０時０分が為す角は(”分”ぶんの60)*2π
    angle = ((hour / 12  *  2 * M_PI) +( M_PI / 6 * minute / 60)) -(minute / 60) * 2 * M_PI ;     //短針と長針のなす角度(ラジアン)
    len = sqrt( pow(short_hand, 2) + pow(long_hand, 2) - 2 * short_hand * long_hand * cos(angle));     //余弦定理で長さを計算

    printf("%.20lf\n", len);

    return 0;
}
