/*
ex4_2
tomatokan
*/
#include<stdio.h>
#include<math.h>

int main(void){
    int hour,minute,hand_hour,hand_minute;
    double angle=0;
    scanf("%d",&hand_hour);
    scanf("%d",&hand_minute);
    scanf("%d",&hour);
    scanf("%d",&minute);
    minute=minute+60*hour;
    angle=minute*11.0*atan(1.0)/90.0;/*時針と分針の間の角度(ラジアン)*/
    printf("%.10f\n",sqrt(hand_hour*hand_hour+hand_minute*hand_minute-2.0*hand_hour*hand_minute*cos(angle)));/*余弦定理より*/
    return 0;
}