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

int main(){
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

    double angle = fabs(30.0 * h - 6.0 * m);
    if(angle > 180)angle = 360 - angle;
    double ans = sqrt(pow(b,2.0) + pow(a,2.0) - 2.0 * b * a * cos(angle * (M_PI / 180.0)));
    printf("%.20lf\n",ans);
    return 0;
}