#include<stdio.h>
#include<math.h>
//#define PI 3.14159265
int main(void){
  double a,b,h,w;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&w);
  double s; //なす角
  s=fabs(360*h/12+0.5*w-360*w/60);
  if(s>180)s-=180;
  //printf("%.10lf\n",s*M_PI);
 // printf("%.10lf\n",s*M_PI/180);
  double sita=s*M_PI/180;
  //printf("%lf %f %lf %lf\n",s,cos(sita),
    //  a*a+b*b,sqrt(a*a+b*b));
  
   double ans=sqrt(a*a+b*b-2*a*b*cos(sita));
  printf("%.20lf",ans);
  return 0;
}