#include<stdio.h>
#include<math.h>
#define pi 3.1415926535897932384
#define eps 1.0e-10

double dbmax(double a,double b){if(a>b){return a;}return b;}

int main(){
  double a,b,h,m,dg;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  dg=fabs(m*60.0-(h*60.0+m)*0.5);
  dg/=360.0;dg*=(2.0*pi);
  if(dg>pi){dg=2*pi-dg;}
  if(fabs(pi-dg)<eps){printf("%.12lf\n",a+b);return 0;}
  if(fabs(dg)<eps){printf("%.12lf\n",dbmax(a,b));return 0;}
  printf("%.12lf\n",fabs(sqrt(a*a+b*b-2.0*a*b*cos(dg))));
}
