#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950
 
int main() {
	int a, b, h, m, min = 0;
	long double rad = 0.0;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	min = h * 60 + m;
	rad = fabs((long double)min * 0.5 - (long double)min * 6.0);
	rad = rad * PI / 180.0;
	long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *b) * cosl(rad);
	printf("%20.20Lf\n", sqrtl(rsq));
	return 0;
}