/* ex4_2
    sak_Citrus*/

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

int main(void){
    //時針・分針の長さとその指す位置
    int hourLength,minuteLength,hour,minute;
    //0時方向から時計回りに測った角
    double hourAngle,minuteAngle;
    //解(の2乗)、角の差(cosの性質から負値も許容)
    double ans,diff;
    scanf("%d %d %d %d",&hourLength,&minuteLength,&hour,&minute);
    minuteAngle = 6 * minute * M_PI / 180; 
    hourAngle = (30 * hour + minute / 2.0) * M_PI / 180;
    diff = minuteAngle - hourAngle;
    //余弦定理
    ans = hourLength*hourLength + minuteLength*minuteLength - 2 * hourLength*minuteLength * cos(diff);
    //ansの平方根を小数点以下10桁まで出力
    printf("%.10lf\n",sqrt(ans));

    return 0;
}