/* ex4_2
   KKOO  */

#include <stdio.h>
#include <math.h>
//円周率を定義する
#define PI 3.1415926536

//プロトタイプ宣言
double cos_low(double hour_length, double minute_length, double hour, double minute);

int main(void){
    double a, b, now_hour, now_minute, ans;
    //時針と分針の長さ、現在の時刻を入力
    scanf("%lf %lf %lf %lf", &a, &b, &now_hour, &now_minute);

    ans = cos_low(a, b, now_hour, now_minute);
    printf("%.9f\n", ans);

    return 0;
}

//関数の定義
double cos_low(double hour_length, double minute_length, double hour, double minute){
    double distance, square_distance, angle, angle_rad;

    //時針と分針の成す角の計算
    angle = fabs(0.5 * (60 * hour + minute) - 6 * minute);
    if(angle > 180){
        angle = 360 - angle;
    }
    //角度をラジアン表記にする
    angle_rad = angle * PI / 180;
    //余弦定理の計算
    square_distance = pow(hour_length, 2) + pow(minute_length, 2) - 2 * hour_length * minute_length * cos(angle_rad);
    distance = sqrt(square_distance);

    return distance;
}
