#include<stdio.h>
#include<math.h>
int main(void){
     double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
     double anga;
     double angb;
    anga=(30*h)+(0.5*m);
    angb=6*m;
     double cosA;
     double ang;
    ang=(anga-angb)*M_PI/180;
    cosA=cos(ang);
     double anss;
     double ans;
    anss=a*a+b*b-2*a*b*cosA;
    ans=sqrt(anss);
    printf("%.20lf\n",ans);
    return 0;
}