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

int main(void) {
    int A, B, H, M;
    
    scanf("%d %d %d %d", &A, &B, &H, &M);

    double h = (double)(H * 60 + M) * 0.5;
    double m = (double)M * 6;
    double hTheta = (90 - h) * (M_PI / 180);
    double mTheta = (90 - m) * (M_PI / 180);
    
    // printf("%f %f \n", h, m);
    // printf("%f %f\n", cos(hTheta), cos(mTheta));

    double a = fabs(A * cos(hTheta) - B * cos(mTheta));
    double b = fabs(A * sin(hTheta) - B * sin(mTheta));

    // printf("%f %f\n", a, b);
    
    double c = sqrt(pow(a, 2.0) + pow(b, 2.0));

    printf("%f\n",c);
    return 0;
}