#include <stdio.h>
#include <math.h>
double pi = 3.14159265358979323846;
double a, b, h, m, t, x;
int main() {
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	h += m / 60;
	t = h / 6 * pi - m / 30 * pi;
	x = a * a + b * b - 2 * a * b * cos(t);
	printf("%.20lf\n", sqrt(x));
}