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

int main(void)
{
    int A, B, H, M;

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

    double H_x, H_y;
    double M_x, M_y;
    double length;

    H_x = A * cos((H*360/12.0) * (2*M_PI/360.0) + (1*(M/60.0)*360/12.0) * (2*M_PI/360.0));
    H_y = A * sin((H*360/12.0) * (2*M_PI/360.0) + (1*(M/60.0)*360/12.0) * (2*M_PI/360.0));

    M_x = B * cos((M*360/60.0) * (2*M_PI/360.0));
    M_y = B * sin((M*360/60.0) * (2*M_PI/360.0));

    length = sqrt((M_x - H_x)*(M_x - H_x) + (M_y - H_y)*(M_y - H_y));

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

    return 0;
}