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

double dabs(double x) {
    if(x >= 0) return x;
    else return (-1)*x;
}

int main(void) {

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

    double thetam = M_PI*M/30.0;
    double thetah = (H/6.00 + M/360.00)*M_PI;

    printf("%.16f\n", sqrt(A*A+B*B-2*A*B*cos(dabs(thetam-thetah))));

    return 0;
}