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

int main(void){

    int A = 0;
    int B = 0;
    double H = 0;
    double M = 0;
    double angle = 0;
    double answer = 0.0;
    scanf("%d %d %lf %lf", &A, &B, &H, &M);

    angle = H * 30.0 + 30.0 * (M / 60.0) - M * 6.0;
    angle = fabs(angle);
    if (angle > 180){
        angle = 360 - angle;
    }
    if (angle == 90){
        answer = sqrt(A * A + B * B);
    } else {
        answer = A * A + B * B - 2 * A * B * cos(angle * 3.1415926535897932 / 180.0);
        answer = sqrt(answer);
    }
    printf("%0.10lf\n", answer);

    return 0;
}