/* kadai4_2
   nabe9393 */

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

int main(void){
  double short_hand, long_hand, hour, minute, angle, answer;
  scanf("%lf %lf %lf %lf", &short_hand, &long_hand, &hour, &minute);
  angle = M_PI * (hour * 30.0 + minute / 2.0 - minute * 6.0) / 180.0 ;
  answer = sqrt( pow(long_hand, 2) + pow(short_hand, 2) - 2 * long_hand * short_hand * cos(angle));
  printf("%.10lf\n", answer);
  return 0;
}