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

int main(){
        int a, b, h, m;
        double ang, len, lon, shor;
        scanf("%d %d %d %d", &a, &b, &h, &m);
        if(h>=12)
                h-=12;

        shor=(double)(h*30+m*0.5);
        lon=(double)(m*6);

        ang=fabs(lon-shor);

        if(ang>(360-ang))
                ang=360-ang;

        len=(double)(a*a*1.0+b*b*1.0-1.0*2*a*b*cos(ang));

        len=sqrt(len);

        printf("%lf", len);

        return 0;
}
