#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//prototype declaration

//gloval variable
double pi = 3.1415926535897932384626433;

int main(void){
    double a, b;
    double h, m;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    double ans = 0;
    double arg = fabs((11*m-60*h)*pi/360);
    ans = sqrt(b*b+a*a-2*a*b*cos(arg));
    printf("%.16lf\n", ans);
    return 0;
}
