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

int main()
{
    const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286l;
    int a, b, h, m;

    scanf("%d %d %d %d", &a, &b, &h, &m);
    int deg = abs(30 * h - 5.5 * m);

    if (deg == 0)
    {
        printf("%.17lf", (double)(abs(a - b)));
    }
    else
    {
        double power = a * a + b * b - 2.0l * a * b * cos(pi * deg / 180.0l);
        printf("%.17lf", sqrt(power));
    }

    return 0;
}