#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define PI 3.14159265358979
int main()
{
	double a,b, c, h, m,d;
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	if (30.0 * h - 6.0 * m + m / 2.0 > 0)
	{
		d = 30.0 * h - 6.0 * m + m / 2.0;
	}
	else
	{
		d= 6.0 * m- 30.0 * h - m / 2.0;
	}
	if (d > 180)
	{
		d = 360.0 - d;
	}
	if (d == 0)
	{
		printf("%.20lf",fabs(b-a));
	}
	else if (d == 180)

	{
		printf("%.20lf", a + b);
	}
	else
	{
		c = sqrt(a * a + b * b - 2.0 * a * b * cos(d * PI / 180.0));
		printf("%.20lf", c);
	}
    return 0;
}