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

int main(int argc, char *argv[]){

  int a, b, h, m;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  //printf("%d %d %d %d\n", a, b, h, m);

  int angle;
  int angle_h = (h * 30) + (m / 2);
  int angle_m = m * 6;
  if(angle_h>angle_m){
    angle = angle_h - angle_m;
  }else if(angle_h == angle_m){
    printf("0\n");
    exit;
  }else{
    angle = angle_m - angle_h;
  }
  if(angle > 180) angle = 360 - angle;
  //printf("angle_h=%d, angle_m=%d, angle=%d\n", angle_h, angle_m, angle);

  double p = 3.141592653589793238462643383279;
  double c = sqrt((a * a) + (b * b) - 2 * (a * b *cos(angle * p / 180.0)));
  printf("%5.20lf\n", c);

  return 0;
}
