// 課題4_2 AtCoder Beginner Contest 168 C - : (Colon)
 
#include<stdio.h>
#include<math.h>
 
int main(void){
    // 時針の長さlength_h cm,分針の長さlength_min cm,時刻hour:min
    int length_h, length_min, hour, min;
    // 結果の格納ans, 短針と時針の間の角度rad
    double ans, rad;
 
    // length_h, length_min, hour, minを受け取る
    scanf("%d %d %d %d", &length_h, &length_min, &hour, &min);

    // intからdoubleに変換
    length_h = (double)length_h;
    length_min = (double)length_min;
    min = (double)min;
    hour = (double)hour;
 
    // 円周率M_PI
    // (分針)ー(時針)cosなので角度の正負は気にしない
    rad = 2.0 * M_PI / 60.0 * min - 2.0 * M_PI / 12 * (hour + min / 60.0);
    // 余弦定理 ans^2
    ans = length_h * length_h + length_min * length_min - 2.0 * length_h * length_min * cos(rad);
    // 平方根をとる
    ans = sqrt(ans);

    printf("%f\n", ans);
    
    return 0;
}