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

int main(void){

    double A, B;
    double H, M, minute;
    double angle_A, angle_B;
    double angle;
    double ans;
    
    scanf("%lf %lf %lf %lf", &A, &B, &H, &M);
    minute = H * 60.0 + M;
    angle_A = minute * ((0.5/360.0)*2.0*M_PI);
    angle_B = M * ((6.0/360.0)*2.0*M_PI);

    angle = fabs(angle_A - angle_B);

    ans = sqrt(pow(A, 2.0) + pow(B, 2.0) - fabs(2.0 * A * B * cos(angle)));

    printf("%.20lf", ans);
    return 0;
}