/* ex4_2 C-:
    dada__  */
#include<stdio.h>
#include<math.h>
#define PI 3.14159265

int main(void){
    int hour_length, min_length, hour, min, past_time_min;
    double deg, distance;

    scanf("%d %d %d %d", &hour_length, &min_length, &hour, &min);

    past_time_min = hour *60 + min; //経過時間を分単位に換算
    deg = (min*PI/30)-(past_time_min*PI/360); //時針と分針の成す角の代入

    //余弦定理による端点間の距離の算出
    distance = sqrt((double) (hour_length*hour_length + min_length*min_length - 2*hour_length*min_length*cos(deg)));
    printf("%f", distance);

    return 0;
}