#include<stdio.h>
#include<math.h>
int main(){
    double a, b, h, m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double ans = M_PI * (m / 30 - (h * 60 + m) / 360);
    printf("%.10f\n",sqrt(a * a + b * b - a * b * cos(ans) * 2));
    return 0;
}