/* ex4_2
   UMAboogie */

#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979 //円周率を定義

int main(void){
  int length_h, length_m, hour, minute;
  scanf("%d %d %d %d", &length_h, &length_m, &hour, &minute); //時針の長さと分針の長さと時間と分を入力

  double angle_h = hour * PI / 6; //時針が進む角度を計算
  double angle_m = minute * PI / 30; //分針が進む角度を計算
  double angle_bet = fabs(angle_h - angle_m); //時針と分針の間の角度を計算

  double answer = sqrt(length_h*length_h + length_m*length_m - 2*length_h*length_m*cos(angle_bet)); //余弦定理を用いて2本の針の端点の距離を計算
  printf("%lf",answer); //答えを出力
  return 0;
}
