#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=h*30+m*0.5;
        lon=m*6;

        ang=fabs(shor-lon);
        ang=ang*M_PI/180;

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

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

        len=sqrt(len);

        printf("%.20f", len);

        return 0;
}
