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


int main() {
	int a,b,h, m;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	double ans, x, y,pi=3.141592653;
	x = fabs(h*30.00-m*5.5);
	y = 1.0*a * a + 1.0*b * b - 2.0 * a * b * cos(x*pi/180);
	ans = sqrt(y);

	printf("%.11f", ans);

	return 0;
}