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

int main() {
	int a, b;
	double h, m;
	scanf("%d%d%lf%lf", &a, &b, &h, &m);
	double ans, pie = 3.14159265358979,x;
	x = pie * fabs(h / 6 - m / 30);
	ans = sqrt(a * a + b * b - 2 * a * b * cos(x));

	printf("%f", ans);

	return 0;
}