#include <stdio.h>
#include <math.h>

int main(void)
{
    int a=0,b=0,h=0,m=0;
    double alf=0.0,beta=0.0,theta=0.0,len=0.0;
    scanf("%d %d %d %d",&a,&b,&h,&m);

    alf=30.0*((double)h+(double)m/60.0);
    beta=(double)m*6.0;

    theta=alf-beta;
    if(theta<0) theta=(-1.0)*theta;

    len=sqrt((double)(a*a)+(double)(b*b)-2*(double)a*(double)b*cos(2*M_PI*theta/360.0));

    printf("%15.11f",len);
    return 0;
}
