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


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

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

    h_theta = 360 * ((60 * h + m) / (60 * 12));
    m_theta = 360 * (m / 60);
    theta = M_PI*fabs(h_theta - m_theta)/180;

    c = pow(a, 2.0) + pow(b, 2.0) - (2 * b * a * cos(theta));

    printf("%lf\n", sqrt(c));

    return 0;
}
