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

int main() {

    double A = 0;
    double B = 0;
    double H = 0;
    double M = 0;
    double x = 0;
    double theta = 0;

    scanf("%lf", &A);
    scanf("%lf", &B);
    scanf("%lf", &H);
    scanf("%lf", &M);


    theta = abs(6 * M - (30 * H + 0.5 * M));
    if (theta > 180) theta -= 180;

    x = sqrt(A * A + B * B - 2 * A * B * cos(theta / 360 * 2 * M_PI));

    printf("%.15f", x);
}
