/* ex 4_2
   cy_an  */

#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
double deff2(double r);

int main(void){

    // 変数宣言
    double len_A, len_B, hour, minutes, degree_tmp, degree_rad, length;
    
    // 入力
    scanf("%lf %lf %lf %lf", &len_A, &len_B, &hour, &minutes);

    // 角度(deg)の累積を計算
    degree_tmp = (hour * 60 + minutes) * 11 / 360;
    // 角度(rad)を0に近い値で計算
    degree_rad = deff2(degree_tmp) * PI;
    // 余弦定理を使ってlengthを求める
    length = sqrt(len_A*len_A + len_B*len_B - 2*len_A*len_B*cos(degree_rad));

    // lengthの出力
    printf("%.20lf\n", length);

    return 0;
}
// 0に最も近いmod2を計算する関数
double deff2(double r){
    while(r > 1){
        r -= 2;
    }
    return r;
}