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

int main() {
    double a, b, h, m, d, r;
    scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
    
    h = h * 60;
    m += h;

    d = (720 - m) * 0.5;
    d = (3.1415926535 * d) / 180;

    r = (a*a + b*b) - (2* a*b * cos(d));
    
    printf("%lf", sqrt(r));
    
    return 0;
}