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

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

    double pos_s = h * 5 + m / 12.0;
    double pos_l = m;
    double rad = (pos_s - pos_l) / 30.0 * M_PI;
    
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    printf("%.10f\n", ans);

    return 0;
}
