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

#define diff(a, b) ((a > b) ? (a - b) : (b - a))

int		minute_hand_degree(int m)
{
	return (m * 6);
}

double	hour_hand_degree(int h, int m)
{
	return (h * 30 + m / 2);
}

double	triangle_len(int a, int b, int degree)
{
	return (sqrt(a * a + b * b - 2 * a * b * cos(degree * M_PI / 180)));
}

int		main(void)
{
	int		A, B, H, M;
	double	deg, len;

	scanf("%d %d %d %d", &A, &B, &H, &M);
	deg = diff(hour_hand_degree(H, M), minute_hand_degree(M));
	len = triangle_len(A, B, deg);
	printf("%.20f\n", len);
	return (0);
}