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

int main( int argc, char *argv[] )
{
    int a, b, h, m;
    double th1, th2;
    double x1, y1, x2, y2;
    double l;

    scanf( "%d %d %d %d", &a, &b, &h, &m );

    th1 = (h*60.+m) / 60. * 30. * 3.14159265359 / 180.;
    th2 = m * 6. * 3.14159265359 / 180.;

    x1 = (double)a * sin( th1 );
    x2 = (double)b * sin( th2 );
    y1 = (double)a * cos( th1 );
    y2 = (double)b * cos( th2 );

    l = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
    printf( "%20.15lf\n", l );
}
