#include<string.h>
#include<math.h>
int main()
{               
        int a,b,h,m;
        scanf("%d %d %d %d",&a,&b,&h,&m);
        int k1=2*3.14*m;
        int k2;
        int d=radians(fabs(((11*m)/2)-(30*h)));
        int calc=(a**2+b**2-2*a*b*cos(d));
        int final=sqrt(calc);
        printf("%.9f",final);
}  