#include<stdio.h>
#include<math.h>
int main(void)
{
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    double hour,min;
    long double angle;
    hour = 30*h + ((double)m/2);
    min = 6*m;
    angle = hour - min;
    if(angle<0)
    {
        angle = 0 - angle;
    }
    if(angle>180)
    {
        angle = 360 - angle;
    }
    angle = (angle/180)*M_PI;
    long double c;
    c=(long double)pow(a,2)+(long double)pow(b,2)-2*a*b*(long double)cos(angle);
    printf("%.20lf",sqrt(c));
}
