#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"math.h"

#define pi 3.1415926535898
#define DEC (pi/180)

int main()
{
    int i,j,k,a,b;
    double n,x,yh,ym,h,m;
    scanf("%d %d %lf %lf",&a,&b,&h,&m);
    if(h<=6)
    {
        if(m<=30)
        {
                yh=h*30+m/60*30;
                ym=m/60*360;
                x=((yh-ym)>=0?(yh-ym):(ym-yh));
        }
        else if(m>30)
        {
            yh=180-(h*30+m/60*30);
            ym=(m-30)/60*360;
            x=((yh+ym)<=180?(yh+ym):(yh+ym-180));
        }
    }
    else if(h>6)
    {
        if(m>=30)
        {
            yh=(h-6)*30+m/60*30;
            ym=(m-30)/60*360;
            x=((yh-ym)>=0?(yh-ym):(ym-yh));
        }
        else if(m<30)
        {
            yh=(h-6)*30+m/60*30;
            ym=180-m/60*360;
            x=((yh+ym)<=180?(yh+ym):(yh+ym-180));
        }
    }
    n=sqrt(a*a+b*b-2*a*b*cos(x*DEC));
   // printf("%lf ",x);
    //printf("%lf ",cos(x*DEC));
    printf("%.20lf ",n);

    return 0;
}
