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



int main()
{
    double A,B,H,M;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    double D1,D2,dD;
    D1=(H+M/60)*30,D2=M*6;
    dD=fabs(D1-D2);
    double S;
    S=cos(PI*dD/180);
    double ans;
    ans=sqrt(A*A+B*B-2*A*B*S);
    printf("%.11lf",ans);





    return 0;



}