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

int main() {
	double a, b, h, m;
	scanf("%lf%lf%lf%lf", &a, &b, &h, &m);
	printf("%lf", sqrt(a * a + b * b -  2 * a * b * cos(fabs(3.14159265358979 * 2 * (m / 60 - m / 720 - h / 12)))));
	return 0;
}
