#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,h,m,h1,m1;
    double c,c1;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    if(m==0 && (h==3 || h==9))
        c=sqrt((double)a*a+(double)b*b);
    else if(m==0 && h==6)
        c=(double)a+(double)b;
    else if(m==0 && h==0)
    {
        if(a>=b)
            c=(double)a-(double)b;
        else
            c=(double)b-(double)a;
    }
    else
    {
        h1=(double)h*30+(double)m*0.5;
        m1=(double)m*6;
        if(h1>m1)
        {
            c1=(double)cos((3.141592654/180)*(h1-m1));
            c=(double)sqrt((double)(a*a)+(double)(b*b)-2*a*b*c1);
        }
        else
        {
            c1=(double)cos((3.141592654/180)*(m1-h1));
            c=(double)sqrt((a*a)+(b*b)-2*a*b*c1);
        }
    }

    printf("%.9lf",c);
    return 0;
}
