#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 =((30.0*h)+(m/12.0)*6.0-m*6.0)*pi/180;
    l=sqrt(a*a+b*b-2*a*b*cos(k));
    printf("%0.20lf",l);

    return 0;
}
