/*
	ex3_2
	ruuu0048
*/
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359 //πを定義
 
double radian_distance_cos(int hour,int minute); //時針と分針の間の角度の余弦を返す関数
 
int main(void){
 
 
    int hour_length,minute_length; //時針と分針の変数を宣言
    int hour,minute; //時間Hと分Mの変数を宣言
    double distance; //求める距離の変数を宣言
 
    scanf("%d %d %d %d",&hour_length,&minute_length,&hour,&minute); //それぞれ入力
    
    distance = sqrt(pow(hour_length,2) + pow(minute_length,2) - 2 * hour_length * minute_length * radian_distance_cos(hour,minute)); //余弦定理を使う
 
    printf("%.16f\n",distance); //答えを出力
 
    return 0; 
}
 
double radian_distance_cos(int hour,int minute){
 
    double hour_radian,minute_radian; //時針と分針の0時からの角度の変数を宣言
 
    hour_radian = ((double)hour + (double)minute / 60) / 12 * (2 * PI); //ラジアンに変換
 
    minute_radian = (double)minute / 60 * (2 * PI); //ラジアンに変換
 
    return cos(hour_radian - minute_radian); //差の余弦を返す
 
};
