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

int main(void){
    double a, b, hour, minute, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &a, &b, &hour, &minute);
    radh = 2 * PI * (hour + minute / 60) / 12;
    radm = 2 * PI * minute / 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;
}