    #include <stdio.h>
    #include <math.h>
    #define PI 3.14159265359

    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)*PI/180)));
       else
          printf("%f\n",sqrt(a*a+b*b-2.0*a*b*cos(ra*PI/180)));
       return 0;
    }