/*  ex4_2
    L40S38  */
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
 int main(void){
     int hour_length,minute_length,hour,minute;
     scanf("%d %d %d %d",&hour_length,&minute_length,&hour,&minute);
     //hour_length:時針の長さ[cm]
     //minute_length:分針の長さ[cm]
     //hour,minute:hour時minute分
     double dif=(2*M_PI)/(12*60)*(hour*60+minute)-(2*M_PI)/60*minute;
     //dif:時針と分針のなす角[rad]
     //余弦定理を用いてans_2(求める距離の2乗)を求める
     double ans_2=pow(hour_length,2)+pow(minute_length,2)-2*hour_length*minute_length*cos(dif);
     printf("%.9f\n",sqrt(ans_2));
     return 0;
}