#include<stdio.h>
#include<math.h>
int main()
{
	double a, b, h, m;
	scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
	m += 60 * h;
	printf("%.20lf\n", sqrt(a * a + b * b - 2 * a * b * cos(2 * acos(-1) * (m / 12 / 60 - fmod(m, 60) / 60))));
	return 0;
}