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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)

int main(void) {
    int A, B, H, M;
    int mn;
    double Ax, Ay, Bx, By;
    double D;

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

    mn = (H * 60) + M;

    Ax = A * cos(deg_to_rad(((double)(mn / 720.0 * 360))));
    Ay = A * sin(deg_to_rad(((double)(mn / 720.0 * 360))));
    Bx = B * cos(deg_to_rad(((double)(M / 60.0 * 360))));
    By = B * sin(deg_to_rad(((double)(M / 60.0 * 360))));

    D = sqrt(pow((Ax - Bx), 2) + pow((Ay - By), 2));

    printf("%.12lf\n", D);

    return 0;
}
