#include <stdio.h>
#include <unistd.h>
#include <math.h>
#define PI　3.14159265359
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(void){
    double ans, a, b, h, m;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    ans = sqrt(a * a + b * b - 2 * a * b * cos(2 * PI * ((h + m / 60)/ 12 - m / 60)));
    printf("%lf", ans);
    return (0);
}
