/* ex4_2
   kohei0713 */

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

int main(void){
    
    int hourHand, minuteHand, hour, minute;
    
    //input
    scanf("%d %d %d %d", &hourHand, &minuteHand, &hour, &minute);

    //長針短針の角度を計算
    double angle_hourHnad = 30 * hour + 0.5 * minute;
    double angle_minuteHand = 6 * minute;

    //角度の差を計算し,ラジアンに変換
    double angle = (angle_hourHnad - angle_minuteHand) * M_PI / 180;

    //余弦定理
    double answer = sqrt(hourHand * hourHand + minuteHand * minuteHand - 2 * hourHand * minuteHand * cos(angle));
    
    //answerを小数点以下10桁表示
    printf("%.10lf\n", answer);

    return 0;
}