#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,h,m;
    double k,l;
    double pi=3.14159265358979;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    k=(double)(((30*h)+(m/60)*30*pi)/180);
    l=(double)(sqrt(a*a+b*b+2*a*b*cos(k)));
    printf("%0.16f",l);

    return 0;
}