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

//精度が出ない

int main(){
    int A, B, H, M;
    scanf("%d%d%d%d", &A, &B, &H, &M);
    double dt;
    dt = H * 30 + M / 2 - M * 6;
    dt = (dt > 0) ? dt : -dt;
    //printf("%d", dt);
    long double C;
    C = A * A + B * B - 2 * A * B * cos(dt *2*acos(-1)/ 360);
    //printf("%Lf\n", C);
    C = sqrt(C);
    printf("%.13Lf\n", C);
    //printf("%lf\n", acos(-1));

    return 0;
}