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

#define PI 3.141592653589793

int main()
{
	int a, b, h, m;
	double c,hx,mx,x;
	scanf("%d%d%d%d", &a, &b, &h, &m);

	mx = (double)m * 6;
	hx = 0.5 * ((double)h * 60 + m);
	if (mx > hx)
	{
		x = mx - hx;
	}
	else
	{
		x = hx - mx;
	}

	if (m==0&&h==0)
	{
		printf("%d\n", abs(a - b));
	}
	else
	{
		c = sqrt((double)a * (double)a + (double)b * (double)b - 2.0 * (double)a * (double)b * cos((double)x * PI / 180.0));
		printf("%.11lf\n", c);
	}
	
	return 0;
}