#include <math.h>
#include <stdio.h>
#define PI 3.14159265359
double min(double x, double y) {
	return x < y ? x : y;
}
int main() {
	int a, b, h, m;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	double an = fabs(6 * m - 0.5 * (h * 60 + m));
	an = min(fabs(180 - an), an);
	long double ans = sqrtl(b * b + a * a - 2 * b * a * cosl(an * PI / 180));
	printf("%.15Lf\n", ans);
	return 0;
}
