#include<stdio.h>
#include<math.h>
#define pi 3.14159265358979

int main(void){
    double A,B,H,M,rad;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    rad=H*pi/6+M*pi/360-M*pi/30;
    double ans=sqrt(A*A+B*B-2*A*B*cos(rad));
    printf("%.9lf\n",ans);
    return 0;
}