#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long double min(long double a, long double b)
{
    return a < b ? a : b;
}

int main(void)
{
    intmax_t A, B, H, M;
    double degree, ans = 0;

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

    degree = fabs(0.5 * ((60 * H) + M) - 6 * M);
    degree = min(360 - degree, degree);

    ans = sqrt(A * A + B * B - 2 * A * B * cos(degree * M_PI / 180));

    printf("%.10f\n", ans);

    return 0;
}
