/* ex 4-4
    kas056 */
#include <stdio.h>
#include <math.h>

int main(void){
    int A,B,HOUR,MINUTE;
    double omega1,omega2,omega,length;

    scanf("%d %d %d %d", &A,&B,&HOUR,&MINUTE);

    omega1 = HOUR * 30.0  / 180.0 *M_PI + MINUTE * 0.5 /180.0 *M_PI;
    omega2 = MINUTE * M_PI / 30.0;
    omega = fabs(omega1-omega2);

    if(omega <= M_PI){
        length = sqrt(pow(A,2) + pow(B,2) - 2*A*B*cos(omega));
    }
    else{
        length = sqrt(pow(A,2) + pow(B,2) + 2*A*B*cos(omega));
    }
    printf("%.10lf",length);
    return 0;
}