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

#define PI 3.141592653589793

int main(void) {
	int a = 0;
	int b = 0;
	int h = 0; //時間
	int m = 0; //分
	double radH = 0.0;
	double radM = 0.0;
	double radHM = 0.0;
	double ans = 0.0;

	scanf("%d %d %d %d", &a, &b, &h, &m);

	radH = ((h * 60.0 + m) * 0.50) * PI / 180.0;

	radM = (m * 6.0) * PI / 180.0;

	//printf("%lf %lf", radH, radM);

	radHM = fabs(radH - radM);

	ans = sqrt(a*a + b*b - 2*a*b*cos(radHM));

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

	return 0;
}