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

#define PI 3.14159265358979323846

int main(){
  double a,b,h,m;
  double l,degh,degm,deg,rad;

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

  degm = 6.0 * m;
  degh = (60.0 * h + m) / 2.0;

  if(degm > degh){
    deg = degm - degh;

    while(deg >= 180){
      deg = 360 - deg;
    }
  }
  else{
    deg = degh - degm;
    while(deg >= 180){
      deg = 360 - deg;
    }
  }

  //printf("%f\n",deg);
  rad = deg * PI / 180.0;

  l = sqrt(pow(a,2.0) + pow(b,2.0) - 2*a*b*cos(rad));

  printf("%.20f\n",l);

  return 0;
}