#include<stdio.h>
#include<math.h>
#define PI 3.1415926535
double kkkk(double h,double m) {
	double a, b,c;
	b = m / 60.0;
	if (b == 1)
		b = 0;
	a = (h * 60 + m) / (60 * 12);
	if (a == 1)
		a = 0;
	c = a - b;
	if (c < 0) {
		c = -c;
	}
	if (c > 0.5) {
		c = 1 - c;
	}
	return 2 * PI * c;
}

int main() {

	double a,b,h,m;
	double rad;
	double c2;
	double ans;
	scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
	
	rad= kkkk(h,m);
	c2 = (a * a) + (b * b)- (2 * a * b * cos(rad));
	
	ans = sqrt(c2);

	printf("%f\n", ans);

	return 0;
}
