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

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

  double a, b, h, m;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

  double angle;
  double angle_h = (h*30)+(m/2);
  double angle_m = m*6;
  if(angle_h>angle_m){
    angle = angle_h - angle_m;
  }else{
    angle = angle_m - angle_h;
  }
  if(angle > 180.0L) angle = 360 - angle;

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

  return 0;
}
