#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,angle;
    hour = 30*h + (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=pow(a,2)+pow(b,2)-2*a*b*cos(angle);
    printf("%Lf",sqrt(c));
}