typedef unsigned long long uint64;
typedef long long int64;
typedef char Bool;
#define true 39
#define false 0
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()
{
	double a, b, h, m;
	scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
	double i1 = ((double)h * (double)30) + (m * 0.5);
	double i2 = (double)m * (double)6;
	if (i1 == 0.0) 
	{
		i1 = 360.0;
	}
	if (i2 == 0.0)
	{
		i2 = 360.0;
	}
	double j;

	if (i1 > i2) 
	{
		j = i1 - i2;
		if (j >= 180.0) 
		{
			j = i2 - (i1 - 360.0);
		}
	}
	else
	{
		j = i2 - i1;
		if (j >= 180.0)
		{
			j = i1 - (i2 - 360.0);
		}
	}

	double ans = ((double)a * (double)a) + ((double)b * (double)b) - (2.0 * (double)a * (double)b * cos(j));

	printf("%lf", sqrt(ans));

	return 0;
}