#include <stdio.h>
#include <math.h>
#define _USE_MATH_DEFINES
double A,B,H,M;
int main()
{
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    double len=0,degA=0,degB=0,def_A=0.5,def_B=6.0,deg=0;
    degA=def_A*(H*60.0+M)*M_PI/180.0;
    degB=def_B*M*M_PI/180.0;
    deg=fabs(degA-degB);
//    printf("degA=%lf degB=%lf def=%lf\n",degA,degB,deg);
    len=sqrt(A*A+B*B-2.0*A*B*cos(deg));
    printf("%15.10lf\n",len);
    return 0;
}

