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

int main(void){
    double A,B,H,M,d,ch,cm,c;

    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);

    ch = 30.0*H + 0.5*M;
    cm = 6.0*M;

    if(ch>cm){
        if(ch-cm<=180)
        c = ch-cm;
        if(ch-cm>180)
        c = 360.0 - (ch-cm);
    }else if(cm>ch){
        if(cm-ch<=180)
        c = cm-ch;
        if(cm-ch>180)
        c = 360.0 - (cm-ch);
    }

    d = sqrt(A*A + B*B - 2.0*A*B*cos(c*M_PI/180.0));

    printf("%.15f",d);

    return 0;
}