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

int main()
{
    int a, b, h, m;
    double s, l;

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

    if ((double)(2 * M_PI * m / 60) >= (double)((2 * M_PI * h / 12) + (2 * M_PI / 12) * (m / 60)))
    {
        s = (double)(2 * M_PI * m / 60) - (double)((2 * M_PI * h / 12) + (2 * M_PI / 12) * (m / 60));
        l = sqrt(a * a + b * b - 2 * a * b * cos(s));
        printf("%lf", l);
    }

    if ((double)(2 * M_PI * m / 60) == (double)((2 * M_PI * h / 12) + (2 * M_PI / 12) * (m / 60)))
    {
        l = 0.0;
        printf("%lf", l);
    }

    if ((double)(2 * M_PI * m / 60) <= (double)((2 * M_PI * h / 12) + (2 * M_PI / 12) * (m / 60)))
    {
        s = fabs((double)(2 * M_PI * m / 60) - (double)((2 * M_PI * h / 12) + (2 * M_PI / 12) * (m / 60)));
        l = sqrt(a * a + b * b - 2 * a * b * cos(s));
        printf("%lf", l);
    }
}