#include <stdio.h>
#include <math.h>
#define ABS(x)		((x)<0 ? -(x):(x))

int main(){
    double a, b, h, m;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

    double hdeg, mdeg, diff, square;
    hdeg = ( 360.0 * h ) / 12.0 + ( 30.0 * m ) / 60.0;  //時針の角度
    mdeg = ( 360.0 * m ) / 60.0;                        //分針の角度
 
    diff = ABS( hdeg - mdeg );
    if     ( diff == 180.0 ){ printf("%lf", a+b); return 0; }
    else if( diff >  180.0 ){ diff -= 180.0; }

    square = a*a + b*b - 2*a*b * cos( diff * ( M_PI / 180.0 ) );
    printf("%lf\n", sqrt(square));

    return 0;
}