#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define M_PI 3.14159265358979323846

void main()
{
    int a, b, h, m;
    double theta;

    scanf("%d %d %d %d", &a, &b, &h, &m);
    theta = fabs((double)m / 60.0 - ((double)h / 12.0 + (double)m / 60.0 / 12.0)) * 2.0 * M_PI;
    printf("%.20lf", sqrt(pow(a, 2.0) + pow(b, 2.0) - 2 * a * b * cos(theta)));
}