#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
#include<math.h>

#define min (double)60
#define hour (double)12

typedef struct 
{
    double x; 
    double y;
} rect;


int main()
{
    double a, b, h, m, a_sita, b_sita;
    rect a_rect, b_rect;

    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

    b_sita = (-2*M_PI*m/min) + (M_PI/2);
    a_sita = (-2*M_PI*(h + (m/min))/hour) + (M_PI/2);

    a_rect.x = a*cos(a_sita);
    a_rect.y = a*sin(a_sita);

    b_rect.x = b*cos(b_sita);
    b_rect.y = b*sin(b_sita);

    printf("%.10lf", sqrt(pow((a_rect.x -b_rect.x),2.0) + pow((a_rect.y -b_rect.y),2.0)));

    return 0;
}