#include<stdio.h>
#include<math.h>
#define pi acos(-1.0)
int main()
{
    int a,b,h,m;
    double k,l;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    k=(double)(((30*h)+(0.5*m)-((m/5)*30))*pi/180);
    l=(double)(sqrt(a*a+b*b+2*a*b*cos(k)));
    printf("%0.20lf",l);

    return 0;
}

