#include<stdio.h>
#include<math.h>
#define pi 3.1415926535897932384626433
int main(){
  int a,b,h,m;
  float radh,radm,rad,c,r;
  
  scanf("%d %d %d %d",&a,&b,&h,&m);
  radm=6.0*m;
  radh=30.0*h+0.5*m;
  rad=radm-radh;
  if(rad<0){rad=-rad;}
  r=rad*pi/180.0;
  c=sqrt(a*a+b*b-2*a*b*cos(r));
  printf("%.25lf\n",c);
}