#include <stdio.h>
#include <math.h>

int main(void){
  int len_hour_hand,len_minute_hand,hour,minute;
  double diff_rad,distance;
  scanf("%d %d %d %d",&len_hour_hand,&len_minute_hand,&hour,&minute);
  diff_rad = 11*M_PI*(60*hour+minute)/360;
  distance = sqrt(pow(len_hour_hand,2)+pow(len_minute_hand,2)
                  -2*len_hour_hand*len_minute_hand*cos(diff_rad));
  printf("%.10f\n",distance);
  return 0;
}