#include<stdio.h>
#include<math.h>
int main(){
    double A,B,H,M;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    printf("%f",sqrt(A*A+B*B-2*A*B*cos((60*H+M)*2*3.141592653590/60*11/12)));
    return 0;
}