/*  ex4_2
    hangan2020 */

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

//プロトタイプ宣言
double ClockHandsDistance(double LHLength, double SHLength, double Hour, double Minute);

int main(void){
    double lhlength, shlength, hour, minute;
    double distance;
    //入力 
    scanf("%lf %lf %lf %lf", &lhlength, &shlength, &hour, &minute);
    //離れる距離を計算する関数の実施
    distance = ClockHandsDistance(lhlength, shlength, hour, minute);
    //小数点15位まで出力
    printf("%0.15lf\n", distance);
    return 0;
}

//関数定義
double ClockHandsDistance(double LHLength, double SHLength, double Hour, double Minute){
    double handsangle, hands_distance;
    //ちょうどHour時間になるときの角度
    handsangle = 30*Hour;
    //そのMinute分後の角度 
    handsangle = handsangle - 5.5*Minute;
    //ラジアンに変換
    handsangle = handsangle*(M_PI/180);
    //距離の2畳を計算
    hands_distance = pow(LHLength, 2) + pow(SHLength, 2) - 2*LHLength*SHLength*cos(handsangle);
    //平方根で最終結果の距離を出す
    hands_distance = sqrt(hands_distance);
    return(hands_distance);
}