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

int powerOf(int b,int e)
{
    int power=1;
    while(e>0)
    {
        power=power*b;
        e--;
    }
    return power;
}
int main()
{

    int A,B,H,M;
    float Angle,L,radian;
    scanf("%d%d%d%d",&A,&B,&H,&M);
    Angle=(float)0.5*((60*H)-(11*M));
    if (Angle<0)
    {
        Angle=-Angle;
    }
    if (Angle>180)
    {
        Angle=360-Angle;
    }
    radian = Angle*(M_PI/180.0 );
    L=sqrt(powerOf(A,2)+powerOf(B,2)-(2*A*B*cosf(radian)));
    printf("%.20f",L);
    return 0;
}
