#include <stdio.h>
#include <math.h>
#define PI 3.14159265358

int main(void){
    double a, b, hour, min, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &a, &b, &hour, &min);
    radh = 2*PI * (hour + min / 60) / 12;
    radm = 2*PI * min / 60;
    rad = (radh - radm < PI) ? radh - radm : radm - radh;
    
    ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
    printf("%.10lf", ans);
    return 0;
}
