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

int main(){
   int  a,b,h,m;
   double ra,rb;

   scanf("%d %d %d %d",&a,&b,&h,&m);
   ra=(h*60.0+m)/2;
   rb=m*6;
   if (ra>rb) ra-=rb;
   else       ra=rb-ra;
   if (ra>180) ra=360-ra;
   if (ra>90)
      printf("%f\n",sqrt(a*a+b*b+2.0*a*b*cos((180-ra)*3.14159927/180)));
   else
      printf("%f\n",sqrt(a*a+b*b-2.0*a*b*cos(ra*3.14159927/180)));
   return 0;
}
