#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 = fmod(((11.0/360.0)*M_PI*minute) , (2.0 * M_PI));

    if(angle<=M_PI){
    ans = sqrt(pow(A, 2.0) + pow(B, 2.0) - 2.0 * A * B * cos(angle));
    }else{
        ans = sqrt(pow(A, 2.0) + pow(B, 2.0) + 2.0 * A * B * cos(angle));
    }
    printf("%.20lf", ans);
    return 0;
}